Beruflich Dokumente
Kultur Dokumente
1) What is C language?
Ans:
C is a programming language developed at AT & Ts Bell Laboratories of USA in 1972.
The C programming language is a standardized programming language developed in the
early 1970s by Ken Thompson and Dennis Ritchie for use on the UNIX operating
system.
It has since spread to many other operating systems, and is one of the most widely used
programming languages.
2) What is an algorithm?
Ans: An algorithm is a step-by-step method of performing any task.
4) What is a C Preprocessor?
Ans: C Preprocessor is a program that processes our source program before it is passed to
the compiler.
15) What is a Data Type and List the different Data types?
Ans: C data types are defined as the data storage format that a variable can store a data to
perform a specific operation.
List of Data Types:
1) Basic Data Types: Int, Float, Char, Double, long int
2) Enumeration Data Type: enum
3) Derived Data Type: Pointer, array, structure, union
4) Void Data Type: void
storage
S.No C Data types Range
Size
1 char 1 127 to 127
2 int 2 32,767 to 32,767
1E37 to 1E+37 with six digits of
3 float 4
precision
1E37 to 1E+37 with ten digits of
4 double 8
precision
1E37 to 1E+37 with ten digits of
5 long double 10
precision
6 long int 4 2,147,483,647 to 2,147,483,647
7 short int 2 32,767 to 32,767
8 unsigned short int 2 0 to 65,535
9 signed short int 2 32,767 to 32,767
10 long long int 8 (2power(63) 1) to 2(power)63 1
11 signed long int 4 2,147,483,647 to 2,147,483,647
12 unsigned long int 4 0 to 4,294,967,295
Unsigned long
13 8 2(power)64 1
long int
22) How many Keywords are there in C and List out the Keywords?
Ans : There are 33 reserved keywords are there in C. They are:
auto else long switch
break enum register typedef
case extern return union
char float short unsigned
const for signed void
continue goto sizeof volatile
default if static while
do int struct _Packed
double
40) What are the Format Specifiers or Type Specifiers or Conversion Specifiers?
Ans: %d (Integer), %f (Float), %c (Character), %l (Long Integer), %s (Strings), %u
(Address with decimal value), %p (Address with Hexa Decimal Value in Small Letters),
%x ((Address with Hexa Decimal Value in Capital Letters)
where
<case list>
is a sequence of
case <value>: <statement list>
break;
and optionally one
default: <statement list>
break;
58) Define goto and labeled Statement, Write syntax for goto and labeled statements?
Ans: The goto statement transfers control to a label. The given label must reside in the
same function and can appear before only one statement in the same function.
Syntax:
goto <label>;
<label>: <Statement>;
Initial /
Storage Storage
S.No. default Scope Life
Specifier place
value
CPU Garbage Within the function
1 auto local
Memory value only.
Till the end of the
main
CPU program. Variable
2 extern Zero Global
memory definition might be
anywhere in the C
program
Retains the value of
CPU the variable
3 static Zero local
memory between different
function calls.
Register Garbage
4 register local Within the function
memory value
71) What is the syntax for One Dimensional Array, explain declaration, Initialization,
accessing the elements?
Ans:
Syntax : data-type arr_name[array_size];
Array
Array initialization Accessing array
declaration
Syntax:
data_type arr_name
data_type
[arr_size]= arr_name[index];
arr_name
(value1, value2, value3,.);
[arr_size];
age[0];_/*0_is_accessed*/
int age [5]; int age[5]={0, 1, 2, 3, 4, 5}; age[1];_/*1_is_accessed*/
age[2];_/*2_is_accessed*/
char str[10]={H,a,i}; (or)
str[0];_/*H is accessed*/
char char str[0] = H;
str[1]; /*a is accessed*/
str[10]; char str[1] = a;
str[2]; /* i is accessed*/
char str[2] = i;
72) What is the syntax for One Dimensional Array, explain declaration, Initialization,
accessing the elements?
Ans: Two dimensional array is nothing but array of array.
syntax : data_type array_name[num_of_rows][num_of_column]
S.no Array declaration Array initialization Accessing array
Syntax: data_type arr_name[2][2]
1 data_type arr_name = arr_name[index];
[num_of_rows][num_of_column]; {{0,0},{0,1},{1,0},{1,1}};
2 Example: int arr[2][2] = {1,2, 3, 4}; arr [0] [0] = 1;
in str1.
strrchr() last occurrence of given character in a Strrchr(str,charcater);
string is found
strstr() Returns pointer to first occurrence of str2 Strstr(str1,str2);
in str1.
strrstr() Returns pointer to last occurrence of str2 Strstr(str1,str2);
in str1.
Strrev() reverses the given string Strstr(str1);
93) Define Function Declaration, Function Call and Function Definition with Syntaxes:
Ans:
Function declaration or prototype - This informs compiler about the function
name, function parameters and return values data type.
Function call This calls the actual function
Function definition This contains all the statements to be executed.
C function
S.no syntax
aspects
function return_type function_name ( arguments list )
1
definition { Body of function; }
2 function call function_name ( arguments list );
function
3 return_type function_name ( argument list );
declaration