300+ TOP C PROGRAMMING Multiple Choice Questions and Answers
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 1 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
B. error
C. 1
D. garbage value
Answer: A
6. 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
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 2 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 3 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
case 3:
printf(“bye”);
}
}
A. error
B. goodbye
C. bye
D. byegoodbye
Answer: A
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 4 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 5 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
C. 5
D. none of these
Answer: A
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 6 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
int s=0;
while(s++<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
Answer: C
20. 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
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 7 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
D. address of I
Answer: 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
Answer: C
24. #include
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 8 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
void func()
{
int x = 0;
static int y = 0;
x++; y++;
printf( “%d — %dn”, 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
Answer: D
With what do you replace 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;
Answer: D
27. 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:
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 10 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
i += 5;
break;
}
printf(“i = %dn”, i);
What will the output of the sample code above be?
A. i = 5
B. i = 8
C. i = 9
D. i = 10
Answer: A
28. 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
29.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++));
}
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 11 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
A.c
B.c++
C.#c/c++
D.c/c++
(e)Compiler error
Answer: D
30. What will be output if you will compile and execute the following c
code?
#define message “union is
power of c”
void main()
{
clrscr();
printf(“%s”,message);
getch();
}
A. union is power of c
B. union is power of c
C. union is Power of c
D. Compiler error
(e) None of these
Answer: B
31. 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
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 12 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
B. 025 0x25
C. 12 42
D. 31 19
(e) None of these
Answer: D
32. 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
33.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();
}
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 13 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
int x=23;
A. 0
B. 2
C. 23
D. Compiler error
(e) None of these
Answer: C
34.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
35.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);
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 14 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
getch();
}
int call(int address){
address++;
return address;
}
A. 0
B. 1
C. Garbage value
D. Compiler error
(e) None of these
Answer: B
36. 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
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 hit key in the key board
{
i.x.ax=3; //get mouse position
x=o.x.cx;
y=o.x.dx;
clrscr();
printf(“(%d , %D.”,x,y);
delay(250);
int86(0x33,&i,&o);
}
getch();
}
38.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
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 16 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
E. Compiler error
Answer: D
39.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
40.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
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 17 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
41.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
42. What will be output if you will compile and execute the following c
code?
#define message “union is
power of c”
void main(){
clrscr();
printf(“%s”,message);
getch();
}
A. 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
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 18 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
43. 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
44. 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
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 19 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
45.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
46.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
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 20 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
47.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
48.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
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 21 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
49.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
50.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
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 22 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
51.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
52.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
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 23 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
53. What will be output if you will compile and execute the following c
code?
#define message “union is
power of c”
void main(){
clrscr();
printf(“%s”,message);
getch();
}
A. 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
54. 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
55.What will be output if you will compile and execute the following c
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 24 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
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
56.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
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 25 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
57.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
58.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
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 26 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
C. Garbage value
D. Compiler error
(e) None of these
Answer: B
59.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.
60.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
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 27 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
Answer: D.
64. C programs are converted into machine language with the help of
A. An Editor
B. A compiler
C. An operating system
D. None of the above
Answer: B
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 28 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 29 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
locations.
A. Sequential
B. Random
C. Sequential and Random
D. None of the above
Answer: A
71. 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: D
Answer: B
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 32 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
B. 27
C. 26
D. None of the above
Answer: D
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 33 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
Answer: D
95. 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
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 35 of 36
300+ TOP C PROGRAMMING Multiple Choice Questions and Answers 03/02/22, 11:59 PM
C. Call by Address
D. Call by Name
Answer: A
https://engineeringinterviewquestions.com/c-programming-multiple-choice-questions-answers/ Page 36 of 36