C Programming Questions
C Programming Questions
C Programming Questions
1) What is C language?
Ans:
C is a programming language developed at AT & T’s 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.
9) What is a Compiler?
Ans: A compiler is a computer program (or set of programs) that transforms source
code written in a programming language (the source language) into another computer
language (the target language, often having a binary form known as object code).
storage
S.No C Data types Range
Size
(bytes)
1 char 1 –127 to 127
2 int 2 –32,767 to 32,767
1E–37 to 1E+37 with six digits of
3 float 4
precision
1E–37 to 1E+37 with ten digits of
4 double 8
precision
1E–37 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
Unsigned long
13 8 2(power)64 –1
long int
16) What is a Void Data Type?
Ans: Void is an empty data type that has no value.
20) 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
21) Define a Variable?
Ans: A variable is nothing but a name given to a storage area that our programs can
manipulate. Each variable in C has a specific type, which determines the size and layout
of the variable's memory.
Syntax for variable Declaration:
int i,j;
char c, ch;
35) 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) 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;
59) 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;
80) 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 value’s 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