BCA 1st Semester
C Programming MCQs
Top 170 MCQ's C programming
1) Who invented C Language-?
A) Charles Babbage
B) Grahambel
C) Dennis Ritchie
D) Steve Jobs
Answer is (C)
2) C Language is a successor to which language-?
A) FORTRAN
B) D Language
C) BASIC
D) B Language
Answer is (D)
3) C is a which level language-?
A) Low Level
B) High Level
C) Low + High
D) None
Answer is (B)
4) Low level language is -?
A) Human readable like language.
B) language with big program size.
C) language with small program size.
D) Difficult to understand and readability is questionable.
Answer is (D)
5) High level language is a -?
A) Human readable like language.
B) language with small program size.
C) language with big program size.
D) language which is difficult to understand and not human readable.
Answer is (A)
6) Which program outputs "Hello World.." -?
A)
main()
{
scanf("Hello World..");
}
B)
main()
{
printf("Hello World..");
}
C)
main()
{
print("Hello World..");
}
D)
main()
{
scan("Hello World..");
}
Answer is (B)
7) C is _______ type of programming language-?
A) Object Oriented
B) Procedural
C) Bit level language
D) Functional
Answer is (B)
8) What is the present C Language Standard-?
A) C99 ISO/IEC 9899:1999
B) C11 ISO/IEC 9899:2011
C) C05 ISO/IEC 9899:2005
D) C10 ISO/IEC 9899:2010
Answer is (B)
9) What are the new features of C11 or ISO IEC 9899 2011 standard-?
A) Type generic Macros, Static Assertions
B) Multi Threading, Anonymous Unions, quick_exit
C) Bounds Checking Interfaces, Anonymous Strurctures
D) All
Answer is (D)
10) C language was invented in which laboratories-?
A) Uniliver Labs
B) IBM Labs
C) AT&T Bell Labs
D) Verizon Labs
Answer is (C)
11) BCPL Language is also called-?
A) C Language
B) B Language
C) D Language
D) None
Answer is (D)
12) C language was invented to develop which Operating System-?
A) Android
B) Linux
C) Ubuntu
D) Unix
Answer is (D)
13) C language was invented in the year-?
A) 1999
B) 1978
C) 1972
D) 1990
Answer is (C)
14) C language is used in the development of-?
A) Databases
B) Graphic applications
C) Word Processors
D) All of the above
Answer is (D)
15) A C program is a combination of-?
A) Statements
B) Functions
C) Variables
D) All of the above
Answer is (D)
16) Choose correct answer.
#include<stdio.h>
main()
{
/* Multi Line Comment
This line is ignored by compiler
*/
printf("Hello C..");
}
A) #include is a Preprocessor Directive
B) <stdio.h> is a header file with predefined functions like printf, scanf etc
C)
#include
main()
{
}
is a mandatory function to be included in every C Program.
D) All the above
Answer is (D)
17) Correct way of commenting a single line is-?
A) /*printf("Hello C.."); printf ("How are you.");
B) //printf("Hello C.."); printf("How are you.");
C) /*printf("Hello C.."); printf("How are you.");*/
D) /printf("Hello C..");/ printf ("How are you.");
Answer is (B)
18) What is an Identifier in C Language-?
A) Name of a Function or Variable
B) Name of a Macros
C) Name of Structure or Union
D) All the above.
Answer is (D)
19) An Identifier may contain-?
A) Letters a-z, A-Z in Basic character set. Unicode alphabet characters other languages
B) Underscore _ symbol
C) Numbers 0 to 9 Unicode Numbers in other languages
D) All the above
Answer is (D)
20) What is the number of characters used to distinguish Identifier or Names of Functions and Global variables-?
A) 31
B) 32
C) 33
D) 28
Answer is (A)
21) What is length of an Identifier that is unique for Non Global Variables and Non Function Names.?
A) 32
B) 63
C) 64
D) 68
Answer is (B)
22) An Identifier can start with-?
A) Alphabet
B) Underscore ( _ ) sign
C) Any character that can be typed on a keyboard
D) Option A & Option B
Answer is (D)
23) C Programs are used in-?
A) Any Electronic device which works on some logic and Operating System.
B) Washing machine
C) Fridge, Microwave Ovens
D) All the above.
Answer is (D)
24) What are the types of Constants in C Language-?
A) Primary Constants
B) Secondary Constants
C) Basic Constants and Advanced Constants
D) Primary Constants and Secondary Constants
Answer is (D)
25) Choose correct statements
A) A constant value does not change. A variable value can change according to needs.
B) A constant can change its values. A variable can have one constant value only.
C) There is no restriction on number of values for constants or variables.
D) Constants and Variables cannot be used in a single main function.
Answer is (A)
26) Find an integer constant.
A) 3.145
B) 34
C) "125"
D) None of the above
Answer is (B)
27) Find a Floating-Point constant.
A) 12.3E5
B) 12e34
C) 125.34857
D) All the above.
Answer is (D)
28) Find a Character constant.
A)
'A'
'a'
B)
'1'
'9'
C)
'$'
'#'
D) All the above.
Answer is (D)
16) A Variable of a particular type can hold only a constant of the same type. Choose right answer.
A) TRUE
B) FALSE
C) It depends on the place the variable is declared.
D) None of the above.
Answer is (A)
17) Choose a right statement.
A) int myage = 10; int my_age = 10;
B) int myage = 10; int my,age = 10;
C) int myage = 10; int my age = 10;
D) All are right
Answer is (D)
18) Number of Keywords present in C Language are -?
A) 32
B) 34
C) 62
D) 64
Answer is (A)
19) Each statement in a C program should end with-?
A) Semicolon ;
B) Colon :
C) Period . (dot symbol)
D) None of the above.
Answer is (A)
20) Choose a correct statement.
A) C Compiler converts your C program into machine readable language.
B) C Editor allows you to type C Programs. It is just like a Notepad with extra options.
C) Console shows the output of a C Program if it is text output.
D) All the above
Answer is (D)
21) Identify wrong C Keywords below.
A) auto, double, int, struct
B) break, else, long, switch
C) case, enum, register, typedef
D) char, extern, intern, return
Answer is (D)
22) Identify wrong C Keywords below.
A) union, const, var, float
B) short, unsigned, continue, for
C) signed, void, default, goto
D) sizeof, volatile, do, if
Answer is (A)
23) Identify wrong C Keywords below.
A) static, while, break, goto
B) struct, construct, signed, unsigned
C) short, long, if, else
D) return, enum, struct, do
Answer is (B)
24) Find a correct C Keyword below.
A) breaker
B) go to
C) shorter
D) default
Answer is (D)
25) Find a correct C Keyword below.
A) work
B) case
C) constant
D) permanent
Answer is (B)
26) Find a correct C Keyword.
A) Float
B) Int
C) Long
D) double
Answer is (D)
27) Types of Integers are-?
A) short
B) int
C) long
D) All the above
Answer is (D)
28) Types of Real numbers in C are-?
A) float
B) double
C) long double
D) All the above
Answer is (D)
29) signed and unsigned representation is available for-?
A) short, int, long, char
B) float, double, long double
C) A & B
D) None of the above
Answer is (C)
30) Size of a Turbo C C++ compiler is-?
A) 16 bit
B) 32 bit
C) 64 bit
D) 128 bit
Answer is (A)
31) Size of a GCC or Visual Studio C Compiler is-?
A) 16 bit
B) 32 bit
C) 64 bit
D) 128 bit
Answer is (B)
32) Sizes of short, int and long in a Turbo C C++ compiler in bytes are-?
A) 2, 2, 4
B) 2, 4, 4
C) 4, 8, 16
D) 8, 8, 16
Answer is (A)
33) Sizes of short, int and long in Visual Studio or GCC compiler in bytes are-?
A) 2, 2, 4
B) 2, 4, 4
C) 4, 4, 8
D) 4, 8, 8
Answer is (B)
34) Range of signed char and unsigned char are-?
A) -128 to +127 0 to 255
B) 0 to 255 -128 to +127
C) -128 to -1 0 to +127
D) 0 to +127 -128 to -1
Answer is (A)
35) Ranges of signed int and unsigned int are-?
A) 0 to 65535 -32768 to +32767
B) -32768 to +32767 0 to 65535
C) -32767 to +32768 0 to 65536
D) 0 to 65536 -32767 to +32768
Answer is (B)
36) Size of float, double and long double in Bytes are-?
A) 4, 8, 16
B) 4, 8, 10
C) 2, 4, 6
D) 4, 6, 8
Answer is (B)
37) Range of singed long and unsigned long variables are-?
A) -2147483647 to +2147483648 0 to 4294967295
B) -2147483648 to +2147483647 0 to 4294967296
C) -2147483648 to +2147483647 0 to 4294967295
D) 0 to 4294967295 -2147483648 to +2147483647
Answer is (C)
38) Range of float variable is.?
A) -3.2e38 to +3.2e38
B) -3.8e32 to +3.8e32
C) -3.4e34 to +3.4e34
D) -3.4e38 to +3.4e38
Answer is (D)
39) Left most bit 0 in Singed representation indicates-?
A) A Positive number
B) A Negative Number
C) An Unsigned number
D) None of the above
Answer is (A)
40) If you do not specify a storage class for a Variable-?
A) You get compiler error.
B) You get a compiler warning.
C) Output is null always
D) None of the above
Answer is (D)
41) What is a C Storage Class-?
A) C Storage decides where to or which memory store the variable.
B) C Storage Class decides what is the default value of a variable.
C) C Storage Class decides what is the Scope and Life of a variable.
D) All the above.
Answer is (D)
42) Every C Variable must have-?
A) Type
B) Storage Class
C) Both Type and Storage Class
D) Either Type or Storage Class
Answer is (C)
43) Find a C Storage Class below.
A) static
B) auto
C) register & extern
D) All the above
Answer is (D)
44) What is the default C Storage Class for a variable-?
A) static
B) auto
C) register
D) extern
Answer is (B)
45) Choose a right answer.
A) auto variable is stored in 'Memory'. static variable is stored in 'Memory'. extern variable is stored in
'Memory'. register variable is stored in 'Memory'.
B) auto variable is stored in 'Memory'. static variable is stored in 'Memory'. extern variable is stored in
'Memory'. register variable is stored in 'Register'.
C) auto variable is stored in 'Register'. static variable is stored in 'Register'. extern variable is stored in
'Register'. register variable is stored in 'Memory'.
D) auto variable is stored in 'Register'. static variable is stored in 'Register'. extern variable is stored in
'Register'. register variable is stored in 'Register'.
Answer is (B)
46) A register variable is stored in a Register. Where does a Register Present in a Computer.?
A) RAM ( Random Access Memory )
B) ROM ( Read Only Memory )
C) CPU (Central Processing Unit )
D) DMA ( Direct Memory Access )
Answer is (C)
47) Variables of type auto, static and extern are all stored in-?
A) ROM
B) RAM
C) CPU
D) Compiler
Answer is (B)
48) Find a right answer.
A) Default value of auto variable = Garbage Value Default value of static = Garbage Value Default value of
extern = Garbage Value Default value of register = Garbage Value
B) Default value of auto variable = zero Default value of static = zero Default value of extern = zero Default
value of register = zero
C) Default value of auto variable = Garbage Default value of static = zero Default value of extern = zero
Default value of register = Garbage
D) Default value of auto variable = zero Default value of static = Garbage Default value of extern = Garbage
Default value of register = zero
Answer is (C)
49) Find a correct statement.
A) Scope of auto variable = local to block or function Scope of register variable = local to block or function
Scope of static variable = local to block or function Scope of extern variable = global or available to all
functions and blocks
B) Scope of auto variable = global or available to all functions and blocks Scope of register variable = global
or available to all functions and blocks Scope of static variable = global or available to all functions and
blocks Scope of extern variable = local to block or function
C) Scope of auto variable = global or available to all functions and blocks Scope of register variable = local
to block or function Scope of static variable = global or available to all functions and blocks Scope of extern
variable = local to block or function
D) Scope of auto variable = local to block or function Scope of register variable = global or available to all
functions and blocks Scope of static variable = local to block or function Scope of extern variable = global
or available to all functions and blocks
Answer is (A)
50) Choose a correct statement.
A) Life of an auto variable = persists between function calls Life of an register variable = with in the block
or function Life of an static variable = persists between function calls Life of an extern variable = until
program ends
B) Life of an auto variable = persists between function calls Life of an register variable = until program ends
Life of an static variable = persists between function calls Life of an extern variable = with in the block or
function
C) Life of an auto variable = until program ends Life of an register variable = until program ends Life of an
static variable = until program ends Life of an extern variable = until program ends
D) Life of an auto variable = with in the block or function Life of an register variable = with in the block or
function Life of an static variable = persists between function calls Life of an extern variable = until
program ends
Answer is (D)
51) Which among the following is a Local Variable-?
A) register
B) auto
C) static
D) extern
Answer is (B)
52) Which among the following is a Global Variable-?
A) auto
B) register
C) static
D) extern
Answer is (D)
53) Choose a correct statement about static variable.
A) A static global variable can be accessed in other files.
B) A static global variable can be used only in a file in which it is declared.
C) A static global variable can not be declared without extern keyword.
D) Default value of a static variable is -1.
Answer is (B)
54) register float a = 3.14f; Choose right statement.
A) Variable a is stored in CPU registers for fast access.
B) Variable a is converted to int and then stored in a CPU register.
C) register Storage Class is ignored and treated as auto float a = 3.14f;
D) You get a compiler error as you can not store non integer value in a CPU register.
Answer is (C)
55) What is the difference between Declaration and Definition-?
A) Declaration does allocate memory for a variable. Definition does allocate memory for a variable.
B) Declaration does allocate memory for a variable. Definition does not allocate memory for a variable.
C) Declaration does not allocate memory for a variable. Definition does allocate memory for a variable.
D) Declaration does not allocate memory for a variable. Definition does not allocate memory for a variable.
Answer is (C)
56) Choose a right statement.
A) A non static global variable can not be used in included files.
B) A non static global variable can be used or referred to inside included files.
C) A non static global variable does not live till the end of program execution.
D) None of the above
Answer is (B)
57) Choose a right statement.
A) Redeclaration of a variable is Ok.
B) Redefinition of a variable is not Ok.
C) Definition of a variable uses memory blocks.
D) All the above.
Answer is (D)
58) Choose a correct statement.
A) Register variables are usually fast retrieving variables.
B) Static variables are usually maintain their values between function calls.
C) Auto variables release their memory after the block or function where they are declared.
D) All the above.
Answer is (D)
59) Choose a right statement.
A) Variables of type auto are stored in Stack memory.
B) Variable of type Static are stored in Segmented Memory.
C) Variables of type register are stored in Micro Processor Memory.
D) All the above.
Answer is (D)
60) Choose a right statement.
A) Variables of type auto are initialized fresh for each block or function call.
B) Variables of type static are initialized only first time the block or function is called.
C) Variables of type register are initialized each time the block or function is executed.
D) All the above.
Answer is (D)
61) Operator % in C Language is called-?
A) Percentage Operator
B) Quotient Operator
C) Modulus
D) Division
Answer is (C)
62) Output of an arithmetic expression with integers and real numbers is ___ by default-?
A) Integer
B) Real number
C) Depends on the numbers used in the expression.
D) None of the above
Answer is (B)
63) Choose a right statement.
int a = 10 + 4.867;
A) a = 10
B) a = 14.867
C) a = 14
D) compiler error.
Answer is (C)
64) Choose a right statement.
int a = 3.5 + 4.5;
A) a = 0
B) a = 7
C) a = 8
D) a = 8.0
Answer is (C)
65) Choose a right statement.
float var = 3.5 + 4.5;
A) var = 8.0
B) var = 8
C) var = 7
D) var = 0.0
Answer is (A)
66) Choose right statement.
int main()
{
float c = 3.5 + 4.5;
printf("%f", c);
return 0;
}
A) 8.0
B) 8.000000
C) 8
D) 7
Answer is (B)
67) Choose a right statement.
int main()
{
float c = 3.5 + 4.5;
printf("%d", (int)c);
return 0;
}
A) 8.0
B) 8.000000
C) 7
D) 8
Answer is (D)
68) Choose a right statement.
int a = 5/2;
int b = 5.0/2;
int c = 5 / 2.0;
int d = 5.0/2.0;
A) a = 2, b = 2, c = 2, d= 2
B) a = 2, b = 2.0, c = 2, d= 2.0
C) a = 2, b = 2.5, c = 2.5, d= 2.5
D) a = 2.5, b = 2.5, c = 2.5, d= 2.5
Answer is (A)
69) Choose a right statement.
float a = 5/2;
float b = 5/2.0;
float c = 5.0/2;
float d = 5.0/2.0;
A) a=2.5, b=2.5, c=2.5, d=2.5
B) a=2, b=2.5, c=2.5, d=2.5
C) a=2.0, b=2.5, c=2.5, d=2.5
D) a=2.0, b=2.0, c=2.0, d=2.0
Answer is (C)
70) If both numerator and denominator of a division operation in C language are integers, then we get-?
A) Expected algebraic real value
B) Unexpected integer value
C) Compiler error.
D) None of the above
Answer is (B)
71) Choose a right statement.
int var = 3.5;
A) a = 3.5
B) a = 3
C) a = 0
D) Compiler error
Answer is (B)
72) Choose a C Conditional Operator from the list.
A) ?:
B) :?
C) :<
D) <:
Answer is (A)
73) What is the other name for C Language ?: Question Mark Colon Operator.?
A) Comparison Operator
B) If-Else Operator
C) Binary Operator
D) Ternary Operator
Answer is (D)
74) Choose a syntax for C Ternary Operator from the list.
A) condition ? expression1 : expression2
B) condition : expression1 ? expression2
C) condition ? expression1 < expression2
D) condition < expression1 ? expression2
Answer is (A)
75) What is the output of the C statement-?
int main()
{
int a=0;
a = 5<2 ? 4 : 3;
20
printf("%d",a);
return 0;
}
A) 4
B) 3
C) 5
D) 2
Answer is (B)
76) What is the output of C Program-?
int main()
{
int a=0;
a = printf("4");
printf("%d",a);
return 0;
}
A) 04
B) compiler error
C) 40
D) 41
Answer is (D)
77) What is the output of the C Program-?
int main()
{
int a=0;
a = 5>2 ? printf("4"): 3;
printf("%d",a);
return 0;
}
A) compiler error
B) 14
C) 41
D) 0
Answer is (C)
78) What is the output of the C Program-?
int main()
{
int a=0;
a = (5>2) ? : 8;
printf("%d",a);
return 0;
}
A) 0
B) 1
C) 8
D) compiler error
Answer is (B)
79) What is the output of C Program-?
int main()
{
int a=0, b;
a = (5>2) ? b=6: b=8;
printf("%d %d",a, b);
return 0;
}
A) 6 6
B) 0 6
C) 0 8
D) compiler error
Answer is (D)
80) Choose a correct statement regarding C Comparison Operators.
A) (x == y) Is x really equal to y. (x != y) Is x not equal to y.
B) (x < y) Is x less than y (x > y) Is x greater than y
C) (x <= y) Is x less than or equal to y. (x >= y) Is x greater than or equal to y
D) All the above
Answer is (D)
81) Choose a statement to use C If Else statement.
A) else if is compulsory to use with if statement.
B) else is compulsory to use with if statement.
C) else or else if is optional with if statement.
D) None of the above
Answer is (C)
82) Choose a correct C Statement using IF Conditional Statement.
A)
if( condition )
{
//statements;
}
B)
if( condition )
{
//statements;
}
else
{
//statements;
}
C)
if( condition1 )
{
//statements;
}
else if( condition2)
{
//statements;
}
else
{
//statements;
}
D) All the above.
Answer is (D)
83) What is the output of the C Program.?
int main()
{
if( 4 > 5 )
{
printf("Hurray..\n");
}
printf("Yes");
23
return 0;
}
A) Yes
B) Hurray.. Yes
C) Hurray..Yes
D) Compiler error
Answer is (A)
84) What is the output of the C Program-?
int main()
{
if( 4 > 5 )
printf("Hurray..\n");
printf("Yes");
return 0;
}
A) Yes
B) Hurray.. Yes
C) Hurray..Yes
D) No Output
Answer is (A)
85) What is the output of the C Program-?
int main()
{
if( 4 < 5 )
printf("Hurray..\n");
printf("Yes");
else
printf("England")
return 0;
}
A) Hurray..Yes
B) Hurray.. Yes
C) Compiler error
D) None of the above
Answer is (C)
86) What is the output of the C Program-?
int main()
{
if( 10 < 9 )
printf("Hurray..\n");
else if(4 > 2)
printf("England");
return 0;
}
A) England
B) Hurray..
C) Compiler error for missing else
D) None of the above
Answer is (A)
87) What is the output of C Program.?
int main()
{
if( 10 > 9 )
printf("Singapore\n");
else if(4%2 == 0)
printf("England\n");
printf("Poland");
return 0;
}
A) Singapore
B) Singapore Poland
C) Singapore England Poland
D) England Poland
Answer is (B)
88) What is the output of the C Program-?
int main()
{
if(-5)
{
printf("Germany\n");
}
if(5)
{
printf("Texas\n");
}
printf("ZING");
25
return 0;
}
A) ZING
B) Texas ZING
C) Germany Texas ZING
D) Compiler error as a number can not be put as condition inside IF.
Answer is (C)
89) What is the output of the C Program?
int main()
{
if(10.0)
{
printf("Texas\n");
}
printf("ZING");
return 0;
}
A) ZING
B) Texas ZING
C) Compiler error.
D) None of the above.
Answer is (B)
90) What is the output of C Program-?
int main()
{
if("abc")
{
printf("India\n");
}
if('c')
{
printf("Honey\n");
}
printf("ZING");
return 0;
}
A) ZING
B) Honey ZING
C) India ZING
D) India Honey ZING
Answer is (D)
91) What is the output of C Program.? int main(){
if(TRUE)
{ printf("India\n");
}
if(true)
{ printf("Honey\n");
}
printf("ZING");
return 0;
}
A) India ZING
B) Honey ZING
C) India Honey ZING
D) Compiler error
Answer is (D)
92) Choose a right C Statement.
A) Loops or Repetition block executes a group of statements repeatedly.
B) Loop is usually executed as long as a condition is met.
C) Loops usually take advantage of Loop Counter
D) All the above.
Answer is (D)
93) Loops in C Language are implemented using-?
A) While Block
B) For Block
C) Do While Block
D) All the above
Answer is (D)
94) Which loop is faster in C Language, for, while or Do While-?
A) for
B) while
C) do while
D) All work at same speed
Answer is (D)
95) Choose correct C while loop syntax.
A)
while(condition)
{
//statements
}
B)
{
//statements
}while(condition)
C)
while(condition);
{
//statements
}
D)
while()
{
if(condition)
{
//statements
}
}
Answer is (A)
96) Choose a correct C for loop syntax.
A) for(initalization; condition; incrementoperation)
{
//statements
}
B) for(declaration; condition; incrementoperation)
{
//statements
}
C) for(declaration; incrementoperation; condition)
{
//statements
}
D) for(initalization; condition; incrementoperation;)
{
//statements
}
Answer is (A)
97) Choose a correct C do while syntax.
A)
dowhile(condition)
{
//statements
}
B)
do while(condition)
{
//statements
}
C)
do
{
//statements
}while(condition)
D)
do
{
//statements
}while(condition);
Answer is (D)
98) What is the output of C Program-?
int main()
{
while(true)
{
printf("RABBIT");
break;
}
return 0;
}
A) RABBIT
B) RABBIT is printed unlimited number of times.
C) No output
D) Compiler error.
Answer is (D)
99) What is the output of C Program-?
int main()
{
int a=5;
while(a==5)
{
printf("RABBIT");
break;
}
return 0;
}
A) RABBIT is printed unlimited number of times
B) RABBIT
C) Compiler error
D) None of the above.
Answer is (B)
100) What is the output of C Program-?
int main()
{
int a=5;
while(a=123)
{
printf("RABBIT\n");
break;
}
printf("GREEN");
return 0;
}
A) GREEN
B) RABBIT GREEN
C) RABBIT is printed unlimited number of times.
D) Compiler error.
Answer (B)
101) What is the output of C Program-?
int main()
{
int a=5;
while(a >= 3);
{
printf("RABBIT\n");
break;
}
printf("GREEN");
return 0;
}
A) GREEN
B) RABBIT GREEN
C) RABBIT is printed infinite times
D) None of the above
Answer is (D)
102) What is the output of C Program-?
int main()
{
int a=25;
while(a <= 27)
{
printf("%d ", a);
a++;
}
return 0;
}
A) 25 25 25
B) 25 26 27
C) 27 27 27
D) Compiler error
Answer is (B)
103) What is the output of C Program-?
int main()
{
int a=32;
do
{
printf("%d ", a);
a++;
}while(a <= 30);
return 0;
}
A) 32
B) 33
C) 30
D) No Output
Answer is (A)
104) What is the output of C Program-?
int main()
{
int a=32;
do
{
printf("%d ", a);
a++;
if(a > 35)
break;
}while(1);
return 0;
}
A) No Output
B) 32 33 34
C) 32 33 34 35
D) Compiler error
Answer is (C)
105) Choose a correct C Statement.
A) a++ is (a=a+1) POST INCREMENT Operator
B) a-- is (a=a-1) POST DECREMENT Opeartor --a is (a=a-1) PRE DECREMENT Opeator
C) ++a is (a=a+1) PRE INCRMENT Operator
D) All the above.
Answer is (D)
106) What is the output of C Program with Switch Statement-?
int main()
{
int a=5;
switch(a)
{
case 0: printf("0 ");
case 3: printf("3 ");
case 5: printf("5 ");
default: printf("RABBIT ");
}
a=10;
switch(a)
{
case 0: printf("0 ");
case 3: printf("3 ");
case 5: printf("5 ");
default: printf("RABBIT "); break;
}
return 0;
}
A) 5 RABBIT
B) 0 3 5 RABBIT 0 3 5 RABBIT
C) 0 3 5 RABBIT RABBIT
D) 3 5 RABBIT RABBIT
Answer is (A)
107) What is the output of C Program with switch statement-?
int main()
{
int a=3;
switch(a) {
case 2: printf("ZERO "); break;
case default: printf("RABBIT "); }
}
A) RABBIT
B) ZERO RABBIT
C) No output
D) Compiler error
Answer is (D)
108) What is the output of C Program with switch statement or block-?
int main()
{
int a=3;
switch(a)
{
}
printf("MySwitch");
}
A) MySwitch
B) No Output
C) Compiler Error
D) None of the above
Answer is (A)
109) What is the output of C Program with switch statement or block-?
int main()
{
int a;
switch(a)
{
printf("APACHE ");
}
printf("HEROHONDA");
}
A) APACHE HEROHONDA
B) HEROHONDA
C) No Output
D) Compiler error
Answer is (B)
110) What is the output of C program with switch statement or block-?
int main()
{
int a;
switch(a);
{
printf("DEER ");
}
printf("LION");
}
A) LION
B) DEER LION
C) Compiler error
D) None of the above
Answer is (B)
111) What is the output of C Program with switch statement or block-?
int main()
{
static int a=5;
switch(a)
{
case 0: printf("ZERO ");break;
case 5: printf("FIVE ");break;
case 10: printf("DEER ");
}
printf("LION");
}
A) ZERO FIVE DEER LION
B) FIVE DEER LION
C) FIVE LION
D) Compiler error
Answer is (C)
112) How many values can a C Function return at a time-?
A) Only One Value
B) Maximum of two values
C) Maximum of three values
D) Maximum of 8 values
Answer is (A)
113) What is the output of a C program with functions-?
void show();
void main()
{
show();
printf("RAINBOW ");
return;
}
void show()
{
printf("COLOURS ");
}
A) RAINBOW COLOURS
B) COLOURS RAINBOW
C) COLOURS
D) Compiler error
Answer is (B)
114) What is the output of C Program-?
void show();
void main()
{
printf("PISTA ");
show();
}
void show()
{
printf("CACHEW ");
return 10;
}
A) PISTA CACHEW
B) CASHEW PISTA
C) PISTA CASHEW with compiler warning
D) Compiler error
Answer is (C)
115) What is the output of C Program with functions-?
int show();
void main()
{
int a;
printf("PISTA COUNT=");
a=show();
printf("%d", a);
}
int show()
{
return 10;
}
A) PISTA COUNT=
B) PISTA COUNT=0
C) PISTA COUNT=10
D) Compiler error
Answer is (C)
116) What is the output of C Program with functions-?
void main()
{
int a;
printf("TIGER COUNT=");
a=show();
printf("%d", a);
}
int show()
{
return 15;
return 35;
}
A) TIGER COUNT=15
B) TIGER COUNT=35
C) TIGER COUNT=0
D) Compiler error
Answer is (A)
118) What are types of Functions in C Language-?
A) Library Functions
B) User Defined Functions
C) Both Library and User Defined
D) None of the above
Answer is (C)
119) What is the output of C program with functions-?
int show();
void main()
{
int a;
a=show();
printf("%d", a);
}
int show()
{
return 15.5;
return 35;
}
A) 15.5
B) 15
C) 0
D) Compiler error
Answer is (B)
120) What is the output of C Program-?
int myshow(int);
void main()
{
myshow(5);
myshow(10);
}
int myshow(int b)
{
printf("Received %d, ", b);
}
A) Received 5, Received 10,
B) Received 10, Received 5,
C) Received 0, Received 0,
D) Compiler error
Answer is (A)
121) What is the output of C Program with functions and pointers-?
int myshow(int);
void main()
{
int a=10;
myshow(a);
myshow(&a);
}
int myshow(int b)
{
printf("Received %d, ", b);
}
A) Received 10, Received 10,
B) Received 10, Received RANDOMNumber,
C) Received 10, Received RANDOMNumber, with a compiler warning
D) Compiler error
Answer is (C)
122) What is the output of C Program with functions and pointers-?
int myshow(int *);
void main()
{
int a=10;
myshow(&a);
}
int myshow(int *k)
{
printf("Received %d, ", *k);
}
A) Received RANDOMNumber,
B) Received 10,
C) Received 10,
D) Compiler error
Answer is (C)
123) What is the output of C Program with functions and pointers-?
void myshow(int *);
void main()
{
int a=10;
printf("%d ", a);
myshow(&a);
printf("%d", a);
}
void myshow(int *k)
{
*k=20;
}
A) 10 10
B) 20 20
C) 10 20
D) Compiler error
Answer is (C)
124) What is the output of C Program with functions-?
void myshow(int);
void main()
{
int a=10;
printf("%d ", a);
myshow(a);
printf("%d", a);
}
void myshow(int k)
{
k=20;
}
A) 10 10
B) 20 20
C) 10 20
D) Compiler error
Answer is (A)
125) Choose correct statements about C Language Pass By Value.
A) Pass By Value copies the variable value in one more memory location.
B) Pass By Value does not use Pointers.
C) Pass By Value protects your source or original variables from changes in outside functions or called
functions.
D) All the above
Answer is (D)
126) What is a String in C Language-?
A) String is a new Data Type in C
B) String is an array of Characters with null character as the last element of array.
C) String is an array of Characters with null character as the first element of array
D) String is an array of Integers with 0 as the last element of array.
Answer is (B)
127) Choose a correct statement about C String.
char ary[]="Hello..!";
A) Character array, ary is a string.
B) ary has no Null character at the end
C) String size is not mentioned
D) String can not contain special characters.
Answer is (A)
128) What is the Format specifier used to print a String or Character array in C Printf or Scanf
function-?
A) %c
B) %C
C) %s
D) %w
Answer is (C)
129) What is the output of C Program with Strings-?
int main()
{
char ary[]="Discovery Channel";
printf("%s",ary);
return 0;
}
A) D
B) Discovery Channel
C) Discovery
D) Compiler error
Answer is (B)
130) What is the output of C Program with Strings-?
int main()
{
char str[]={'g','l','o','b','e'};
printf("%s",str);
return 0;
}
A) g
B) globe
C) globe\0
D) None of the above
Answer is (D)
131) What is the output of C Program with Strings-?
int main()
{
char str[]={'g','l','o','b','y','\0'};
printf("%s",str);
return 0;
}
A) g
B) globe
C) globe\0
D) Compiler error
Answer is (B)
132) How do you convert this char array to string.?
char str[]={'g','l','o','b','y'};
A) str[5] = 0;
B) str[5] = '\0'
C) str[]={'g','l','o','b','y','\0'};
D) All the above
Answer is (D)
133) What is the output of C Program-?
int main()
{
int str[]={'g','l','o','b','y'};
printf("A%c ",str);
printf("A%s ",str);
printf("A%c ",str[0]);
return 0;
}
A) A A A
B) A Ag Ag
C) A*randomchar* Ag Ag
D) Compiler error
Answer is (C)
134) What is the output of C Program with arrays-?
int main()
{
char str[]={"C","A","T","\0"};
printf("%s",str);
return 0;
}
A) C
B) CAT
C) CAT\0
D) Compiler error
Answer is (D)
135) What is the maximum length of a C String-?
A) 32 characters
B) 64 characters
C) 256 characters
D) None of the above
Answer is (D)
136) What is the output of C program with strings-?
int main()
{
char str1[]="JOHN";
char str2[20];
str2= str1;
printf("%s",str2);
return 0;
}
A) JOHN
B) J
C) JOHN\0
D) Compiler error
Answer is (D)
137) What is the output of C Program with arrays-?
int main()
{
char str[25];
scanf("%s", str);
printf("%s",str);
return 0;
}
//input: South Africa
A) South
B) South Africa
C) S
D) Compiler error
Answer is (A)
138) What is the output of C program with strings-?
int main()
{
char str[2];
scanf("%s", str);
printf("%s",str);
return 0;
}
//Input: South
A) So
B) South
C) Compiler error
D) None of the above
Answer is (B)
139) What is the output of C Program with strings-?
int main()
{
char str[2];
int i=0;
scanf("%s", str);
while(str[i] != '\0')
{
printf("%c", str[i]);
i++;
}
return 0;
}
//Input: KLMN
A) KL
B) KLMN
C) Compiler error
D) None of the above
Answer is (B)
140) What is a structure in C language-?
A) A structure is a collection of elements that can be of same data type.
B) A structure is a collection of elements that can be of different data type.
C) Elements of a structure are called members.
D) All the above
Answer is (D)
141) What is the size of a C structure-?
A) C structure is always 128 bytes.
B) Size of C structure is the total bytes of all elements of structure.
C) Size of C structure is the size of largest element.
D) None of the above
Answer is (B)
142) What is the output of C program with structures-?
int main()
{
structure hotel
{
int items;
char name[10];
}a;
strcpy(a.name, "TAJ");
a.items=10;
printf("%s", a.name);
return 0;
}
A) TAJ
B) Empty string
C) Compiler error
D) None of the above
Answer is (C)
143) What is the output of C program-?
int main()
{
struct book
{
int pages;
char name[10];
}a;
a.pages=10;
strcpy(a.name,"Cbasics");
printf("%s=%d", a.name,a.pages);
return 0;
}
A) empty string=10
B) C=basics
C) Cbasics=10
D) Compiler error
Answer is (C)
144) Choose a correct statement about C structures.
A) Structure elements can be initialized at the time of declaration.
B) Structure members can not be initialized at the time of declaration
C) Only integer members of structure can be initialized at the time of declaraion
D) None of the above
Answer is (B)
145) Choose a correct statement about C structure-?
int main()
{
struct ship
{
};
return 0;
}
A) It is wrong to define an empty structure
B) Member variables can be added to a structure even after its first definition.
C) There is no use of defining an empty structure
D) None of the above
Answer is (C)
146) What is the output of C program-?
int main()
{
struct ship
{
int size;
char color[10];
}boat1, boat2;
boat1.size=10;
boat2 = boat1;
printf("boat2=%d",boat2.size);
return 0;
}
A) boat2=0
B) boat2=-1
C) boat2=10
D) Compiler error
Answer is (C)
147) What is the output of C program with structures-?
int main()
{
struct ship
{
char color[10];
}
boat1, boat2;
strcpy(boat1.color,"RED");
printf("%s ",boat1.color);
boat2 = boat1;
strcpy(boat2.color,"YELLOW");
printf("%s",boat1.color);
return 0;
}
A) RED RED
B) RED YELLOW
C) YELLOW YELLOW
D) Compiler error
Answer is (A)
148) What is the output of C program with structures-?
int main()
{
struct tree
{
int h;
}
struct tree tree1;
tree1.h=10;
printf("Height=%d",tree1.h);
return 0;
}
A) Height=0
B) Height=10
C) Height=
D) Compiler error
Answer is (B)
149) Choose a correct statement about C structure elements-?
A) Structure elements are stored on random free memory locations
B) structure elements are stored in register memory locations
C) structure elements are stored in contiguous memory locations
D) None of the above.
Answer is (C)
150) A C Structure or User defined data type is also called-?
A) Derived data type
B) Secondary data type
C) Aggregate data type
D) All the above
Answer is (D)
151) What are the uses of C Structures-?
A) structure is used to implement Linked Lists, Stack and Queue data structures
B) Structures are used in Operating System functionality like Display and Input taking.
C) Structure are used to exchange information with peripherals of PC
D) All the above
Answer is (D)
152) What is the output of C program with structures-?
int main()
{
struct tree
{
int h;
int w;
};
struct tree tree1={10};
printf("%d ",tree1.w);
printf("%d",tree1.h);
return 0;
}
A) 0 0
B) 10 0
C) 0 10
D) 10 10
Answer is (C)
153) What is the output of C program with structures-?
int main()
{
struct tree
{
int h;
int rate;
};
struct tree tree1={0};
printf("%d ",tree1.rate);
printf("%d",tree1.h);
return 0;
}
A) 0 0
B) -1 -1
C) NULL NULL
D) Compiler error
Answer is (A)
154) What is the need for a File when you can store anything in memory-?
A) Memory (RAM) is limited in any computer.
B) A file is stored on Hard Disk which can store Gigabytes of data.
C) File stored on Hard Disk is safe even if PC is switched off. But Memory or RAM contents are cleared
when PC is off.
D) All the above
Answer is (D)
155) What is the keyword used to declare a C file pointer-?
A) file
B) FILE
C) FILEFP
D) filefp
Answer is (B)
156) What is a C FILE data type-?
A) FILE is like a Structure only
B) FILE is like a Union only
C) FILE is like a user define int data type
D) None of the above
Answer is (A)
157) Where is a file temporarily stored before read or write operation in C language-?
A) Notepad
B) RAM
C) Hard disk
D) Buffer
Answer is (D)
158) Choose a correct statement about C file operation program-?
int main()
{
FILE *fp;
char ch;
fp=fopen("readme.txt","r");
while((ch=fgetc(fp)) != EOF)
{
printf("%c",ch);
}
}
A) FOPEN opens a file named readme.txt in Read Mode ("r).
B) EOF is End Of File. ch==EOF checks for end of file and while loop stops or exits.
C) FGETC(fp) is a function that returns one character and cursor goes to next character.
D) All the above
Answer is (D)
159) What is the need for closing a file in C language-?
A) fclose(fp) closes a file to release the memory used in opening a file.
B) Closing a file clears Buffer contents from RAM or memory.
C) Unclosed files occupy memory and PC hangs when on low memory.
D) All the above
Answer is (D)
160) If a FILE pointer is NULL what does it mean-?
FILE *fp;
fp=fopen("abc.txt","w");
A) Unable to open a file named abc.txt
B) abc.txt is not available on disk
C) Hard disk has hard ware problems.
D) All the above
Answer is (D)
160) Choose a correct statement about FGETS in C program-?
int main()
{
FILE *fp;
char str[80];
fp=fopen("readme.txt","r");
while(fgets(str,80,fp) != NULL)
{
printf("%s",str);
}
fclose(fp);
}
A) str in fgets() is a like a user buffer that can store 80 characters each time
B) FGETS returns null if no characters are left
C) fgets() reads content from File. FPUS writes content back to File.
D) All the above
Answer is (D)
161) Choose a correct statement about C file "R" mode operation using fopen.
fopen("abc.txt","r");
A) If the file abc.txt is found, fopen returns a FILE pointer.
B) If the file abc.txt is not found, fopen returns NULL or 0.
C) File abc.txt is only opened in Read Mode. Now write operation is performed.
D) All the above
Answer is (D)
162) Choose a correct statement about File Write Mode "w".
File *fp;
fp=fopen("abc.txt","w");
A) If the file abc.txt is not found File abc.txt is created on disk.
B) If the file abc.txt is found, fopen() returns a FILE pointer as usual. Every time, contents of abt.txt are
overwritten in "w" mode.
C) Read operation is not allowed in "w" mode.
D) All the above
Answer is (D)
163) Choose a correct statement about C File Mode "w+".
FILE *p;
p=fopen("abc.txt","r+");
A) r+ mode allows reading of existing contents of file abc.txt only if file is found.
B) If file is not found, NULL is returned by fopen().
C) You can read existing contents, edit existing content and add new content.
D) All the above
Answer is (D)
164) Choose a correct statement about C file mode "w+".
FILE *fp;
fp=fopen("abc.txt","w+");
A) Like "w" mode, "w+" mode creates a new file abc.txt if not found. NULL is only returned if some other
problems in PC exist in opening a file.
B) w+ mode allows you to read the file also. Only after writing, you can read contents if any written. Before
writing existing contents are emptied.
C) w+ mode always makes a file contents empty like w mode.
D) All the above
Answer is (D)
165) Choose a correct statement about C file mode "a".
FILE *fp;
fp=fopen("abc.txt","a");
A) "a" is for append operation. You can append or add new content to the existing contents.
B) If file is not found, new file is created.
C) You can not write read file contents.
D) All the above
Answer is (D)
166) Choose a correct statement about C file mode "a+".
FILE *fp;
fp=fopen("abc.txt","a+);
A) a+ mode always appends new data to the end of existing content
B) a+ mode creates a new file if not found or existing.
C) a+ mode allows reading also. mode "a" allows only appending not reading.
D) All the above
Answer is (D)
167) Choose a correct statement about opening a file in binary mode for reading.
FILE *fp;
fp=fopen("abc.txt","rb");
A) rb mode opens the file in binary mode
B) Binary mode is just reading or writing in bytes instead of integers, characters or strings.
C) Binary mode saves memory occupied by contents.
D) All the above
Answer is (D)
168) What is the syntax for writing a file in C using binary mode.?
FILE *fp;
A) fp=fopen("abc.txt","wr");
B) fp=fopen("abc.txt","wb");
C) fp=fopen("abc.txt","wbin");
D) fp=fopen("abc.txt","b");
Answer is (B)
169) What are the C functions used to read or write a file in Text Mode-?
A) fprintf(), fscanf()
B) fread(), fwrite()
C) fprint(), fscan()
D) read(), write()
Answer is (A)
170) What are the C functions used to read or write a file in Binary Mode-?
A) fprintf(), fscanf()
B) fread(), rwrite()
C) readf(), writef()
D) printf(), scanf()
Answer is (B)
171) What is the C function used to move current pointer to the beginning of file-?
FILE *fp;
A) rev(fp)
B) rewind(fp)
C) rew(fp)
D) wind(fp)
Answer is (B)
172) Choose a correct syntax for FSCANF and FPRINTF in c language-?
A) fprintf("format specifier",variables, fp); fscanf("format specifier",variables, fp);
B) fprintf(fp,count,"format specifier",variables); fscanf(fp,count,"format specifier",variables);
C) fprintf(fp,"format specifier",variables); fscanf(fp,"format specifier",variables);
D) None of the above
Answer is (C)
You May Also Like:-
Don't forget to comment.
No comments:
Post a Comment