C Language MCQ's
C Language MCQ's
C Language MCQ's
Answer : B
Answer : A
Answer : C
Answer : B
Answer : D
Answer : C
Answer : D
8. What is an array?
A. An array is a collection of variables that are of the dissimilar data type.
B. An array is a collection of variables that are of the same data type.
C. An array is not a collection of variables that are of the same data type.
D. None of the above.
Answer : B
Answer : A
10. An array elements are always stored in _________ memory locations.
A. Sequential
B. Random
C. Sequential and Random
D. None of the above
Answer : A
11. What is the right way to access value of structure variable book{ price, page }?
A. printf("%d%d", book.price, book.page);
B. printf("%d%d", price.book, page.book);
C. printf("%d%d", price::book, page::book);
D. printf("%d%d", price->book, page->book);
Answer : A
Answer : B
Answer : D
Answer : C
Answer : A
Answer : D
Answer : B
19. In switch statement, each case instance value must be _______?
A. Constant
B. Variable
C. Special Symbol
D. None of the above
Answer : A
Answer : C
Answer : D
Answer : B
Answer : D
Answer : B
Answer : D
Answer : D
Answer : D
Answer : B
Answer : D
Answer : C
31. The _______ memory allocation function modifies the previous allocated
space.
A. calloc
B. free
C. malloc
D. realloc
Answer : D
Answer : A
34. The worst case time complexity of AVL tree is better in comparison to binary
search tree for
A. Search and Insert Operations
B. Search and Delete Operations
C. Insert and Delete Operations
D. Search, Insert and Delete Operations
Answer : D
35. In which tree, for every node the height of its left subtree and right subtree
differ almost by one?
A. Binary search tree
B. AVL tree
C. Threaded Binary Tree
D. Complete Binary Tree
Answer : B
Answer : A
Answer : B
Answer : C
Answer : D
Ans: d
Ans: b
Ans: a
Ans: c
1:
printf("goodbye"); break;
case 2:
continue;
case 3:
printf("bye");
}
}
a) error
b) goodbye
c) bye
d) byegoodbye
Ans: a
Ans: d
48. main()
{
struct
{
int i;
}xyz;
(*xyz)->i=10;
printf("%d",xyz.i);
}
What is the output of this program?
a) program will not compile
b) 10
c) god only knows
d) address of I
Ans: b
sizeof(str));
}
a) 7
b) 6
c) 5
d) error
Ans: b
23. What will be the value of `a` after the following code is executed
#define square(x) x*x
a = square(2+3)
a) 25
b) 13
c) 11
d) 10
Ans: c
24. #include
void func()
{
int x = 0;
static int y = 0;
x++; y++;
printf( "%d -- %d\n", x,
y );
}
int main()
{
func();
func();
return 0;
}
What will the code above print when it is
executed?
a)
1 -- 1
1 -- 1
b)
1 -- 1
2 -- 1
c)
1 -- 1
2 -- 2
d)
1 -- 1
1 -- 2
Ans: d
the ???? to make the function shown above return the correct answer?
a)if (x == 0)
return 0;
b)return 1;
c)if (x >= 2) return 2;
d)if (x <= 1) return 1;
Ans: d
Ans: d
52. int i = 4;
switch (i)
{
default: ;
case 3:
i += 5;
if ( i == 8)
{
i++;
if (i == 9) break;
i
*= 2;
}
i -= 4;
break;
case 8:
i += 5;
break;
}
printf("i = %d\n", i);
What will the output of
Ans: a
53. What will be output if you will compile and execute the following c code?
void
main()
{
if(printf("cquestionbank"))
printf("I know c");
else
printf("I know c++");
}
(a) I
know c
(b) I know c++
(c) cquestionbankI know c
(d) cquestionbankI know c++
(e) Compiler
error
Answer: (c)
54.What will be output if you will compile and execute the following c code?
#define
call(x) #x
void main(){
printf("%s",call(c/c++));
}
(a)c
(b)c++
(c)#c/c++
(d)c/c++
(e)Compiler
error
Answer: (d)
55. What will be output if you will compile and execute the following c code?
#define
Answer: (b)
56. What will be output if you will compile and execute the following c code?
void
main(){
int a=25;
clrscr();
printf("%o %x",a,a);
getch();
}
(a) 25 25
(b) 025 0x25
(c) 12 42
(d) 31 19
(e) None of these
Answer: (d)
57. What will be output if you will compile and execute the following c code?
void
main()
{
int i=0;
if(i==0){
i=((5,(i=3)),i=1);
printf("%d",i);
}
else
printf("equal");
}
(a) 5
(b) 3
(c) 1
(d) equal
(e) None of above
Answer: (c)
58.What will be output if you will compile and execute the following c code?
int extern
x;
void main()
printf("%d",x);
x=2;
getch();
}
int x=23;
(a) 0
(b) 2
(c) 23
(d) Compiler error
(e) None of these
Answer: (c)
59.What will be output if you will compile and execute the following c code?
void main
(){
int a,b;
a=1,3,15;
b=(2,4,6);
clrscr();
printf("%d ",a+b);
getch();
}
(a) 3
(b) 21
(c) 17
(d)
7
(e) Compiler error
Answer: (d)
60.What will be output if you will compile and execute the following c code?
void main
(){
static main;
int x;
x=call(main);
clrscr();
printf("%d ",x);
getch();
}
int call(int
address){
address++;
return address;
}
(a) 0
(b) 1
(c) Garbage value
(d) Compiler error
(e)
None of these
Answer: (b)
61. What will be output if you will compile and execute the following c code?
#include
"string.h"
void main(){
clrscr();
printf("%d %d",sizeof("string"),strlen("string"));
getch();
}
(a) 6 6
(b) 7 7
(c) 6 7
(d) 7 6
(e) None of these
Answer: (d)
62. Write c program which display mouse pointer and position of pointer.(In x
coordinate, y coordinate)?
Answer:
void main()
{
union REGS i,o;
int x,y,k;
//show
mouse pointer
i.x.ax=1;
int86(0x33,&i,&o);
while(!kbhit()) //its value will false when we
63.What will be output if you will compile and execute the following c code?
void main
(){
int huge*p=(int huge*)0XC0563331;
int huge*q=(int huge*)0xC2551341;
*p=200;
printf
("%d",*q);
}
(a)0
(b)Garbage value
(c)null
(d) 200
(e)Compiler error
Answer: (d)
64.What will be output if you will compile and execute the following c code?
struct
marks{
int p:3;
int c:3;
int m:2;
};
void main(){
struct marks s={2,-6,5};
printf("%d %d
%d",s.p,s.c,s.m);
}
(a) 2 -6 5
(b) 2 -6 1
(c) 2 2 1
(d) Compiler error
(e) None of these
Answer: (c)
65.What will be output if you will compile and execute the following c code?
void main
(){
if(printf("cquestionbank"))
printf("I know c");
else
printf("I know c++");
}
(a) I know
c
(b) I know c++
(c) cquestionbankI know c
(d) cquestionbankI know c++
(e) Compiler error
Answer: (c)
66.What will be output if you will compile and execute the following c code?
#define
call(x) #x
void main(){
printf("%s",call(c/c++));
}
(a)c
(b)c++
(c)#c/c++
(d)c/c++
(e)Compiler
error
Answer: (d)
67. What will be output if you will compile and execute the following c code?
#define
union is power of c
(b) union ispower of c
(c) union is
Power of c
(d) Compiler error
(e)
None of these
Answer: (b)
68. What will be output if you will compile and execute the following c code?
void
main(){
int a=25;
clrscr();
printf("%o %x",a,a);
getch();
}
(a) 25 25
(b) 025 0x25
(c) 12 42
(d) 31 19
(e) None of these
Answer: (d)
69. What will be output if you will compile and execute the following c code?
void
main(){
int i=0;
if(i==0){
i=((5,(i=3)),i=1);
printf("%d",i);
}
else
printf("equal");
}
(a) 5
(b) 3
(c) 1
(d) equal
(e) None of above
Answer: (c)
70.What will be output if you will compile and execute the following c code?
int extern
x;
void main()
printf("%d",x);
x=2;
getch();
}
int x=23;
(a) 0
(b) 2
(c) 23
(d) Compiler error
(e) None of these
Answer: (c)
71.What will be output if you will compile and execute the following c code?
void main
(){
int a,b;
a=1,3,15;
b=(2,4,6);
clrscr();
printf("%d ",a+b);
getch();
}
(a) 3
(b) 21
(c) 17
(d)
7
(e) Compiler error
Answer: (d)
72.What will be output if you will compile and execute the following c code?
void main
(){
static main;
int x;
x=call(main);
clrscr();
printf("%d ",x);
getch();
}
int call(int
address){
address++;
return address;
}
(a) 0
(b) 1
(c) Garbage value
(d) Compiler error
(e)
None of these
Answer: (b)
73.What will be output if you will compile and execute the following c code?
#include
"string.h"
void main(){
clrscr();
printf("%d %d",sizeof("string"),strlen("string"));
getch();
}
(a) 6 6
(b) 7 7
(c) 6 7
(d) 7 6
(e) None of these
Answer: (d)
74.What will be output if you will compile and execute the following c code?
void main
(){
int huge*p=(int huge*)0XC0563331;
int huge*q=(int huge*)0xC2551341;
*p=200;
printf
("%d",*q);
}
(a)0
(b)Garbage value
(c)null
(d) 200
(e)Compiler error
Answer: (d)
75.What will be output if you will compile and execute the following c code?
struct
marks{
int p:3;
int c:3;
int m:2;
};
void main(){
struct marks s={2,-6,5};
printf("%d %d
%d",s.p,s.c,s.m);
}
(a) 2 -6 5
(b) 2 -6 1
(c) 2 2 1
(d) Compiler error
(e) None of these
Answer: (c)
76.What will be output if you will compile and execute the following c code?
void main
(){
if(printf("cquestionbank"))
printf("I know c");
else
printf("I know c++");
}
(a) I know
c
(b) I know c++
(c) cquestionbankI know c
(d) cquestionbankI know c++
(e) Compiler error
Answer: (c)
77.What will be output if you will compile and execute the following c code?
#define
call(x) #x
void main(){
printf("%s",call(c/c++));
}
(a)c
(b)c++
(c)#c/c++
(d)c/c++
(e)Compiler
error
Answer: (d)
78. What will be output if you will compile and execute the following c code?
#define
union is power of c
(b) union ispower of c
(c) union is
Power of c
(d) Compiler error
(e)
None of these
Answer: (b)
79. What will be output if you will compile and execute the following c code?
void
main(){
int a=25;
clrscr();
printf("%o %x",a,a);
getch();
}
(a) 25 25
(b) 025 0x25
(c) 12 42
(d) 31 19
(e) None of these
Answer: (d)
80.What will be output if you will compile and execute the following c code?
void main
(){
int i=0;
if(i==0){
i=((5,(i=3)),i=1);
printf("%d",i);
}
else
printf("equal");
}
(a) 5
(b) 3
(c) 1
(d) equal
(e) None of above
Answer: (c)
81.What will be output if you will compile and execute the following c code?
int extern
x;
void main()
printf("%d",x);
x=2;
getch();
}
int x=23;
(a) 0
(b) 2
(c) 23
(d) Compiler error
(e) None of these
Answer: (c)
82.What will be output if you will compile and execute the following c code?
void main
(){
int a,b;
a=1,3,15;
b=(2,4,6);
clrscr();
printf("%d ",a+b);
getch();
}
(a) 3
(b) 21
(c) 17
(d)
7
(e) Compiler error
Answer: (d)
83.What will be output if you will compile and execute the following c code?
void main
(){
static main;
int x;
x=call(main);
clrscr();
printf("%d ",x);
getch();
}
int call(int
address){
address++;
return address;
}
(a) 0
(b) 1
(c) Garbage value
(d) Compiler error
(e)
None of these
Answer: (b)
84.What will be output if you will compile and execute the following c code?
#include
"string.h"
void main(){
clrscr();
printf("%d %d",sizeof("string"),strlen("string"));
getch();
}
(a) 6 6
(b) 7 7
(c) 6 7
(d) 7 6
(e) None of these
Answer: (d)
85.What will be output if you will compile and execute the following c code?
void main
(){
int huge*p=(int huge*)0XC0563331;
int huge*q=(int huge*)0xC2551341;
*p=200;
printf
("%d",*q);
}
(a)0
(b)Garbage value
(c)null
(d) 200
(e)Compiler error
Answer: (d)
86. What is the right way to access value of structure variable book{ price, page }?
A.
Answer : A
of the above
Answer : B
and floats
D. ints and chars
Answer : D
Answer : D
be changed.
B. Keywords have some unknown meanings and these meanings cannot be
changed.
C. Keywords have some predefine meanings and these meanings cannot be
changed.
D. None of the above
Answer : C
91.What is constant?
A. Constants have fixed values that do not change during the
execution of a program
B. Constants have fixed values that change during the execution
of a program
C. Constants have unknown values that may be change during the execution
of a program
D. None of the above
Answer : A
Answer : D
the avobe
Answer : B
Variable
C. Special Symbol
D. None of the avobe
Answer : A
of program
C. Exit from loop or switch statement
D. None of the avobe
Answer : C
Ans: b
b = 9;
printf("%d",a>>a/b-2);
}
a) 9
b) 7
c) 5
d) none of these
Ans: a
Ans: a
output?
a) XAM is printed
b) exam is printed
c) Compiler Error
d) Nothing is printed
Ans: d
+<10)>
# define a 10
main()
{
printf("%d..",a);
foo();
printf("%d",a);
}
void foo()
{
#undef a
#define a 50
}
a) 10..10
b) 10..50
c) Error
d) 0
Ans: c