Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Worksheet/programming/IUSTY/HND/NGAKAM

100 TOP C Language Multiple Choice 5. A C variable cannot start with


1. Who is father of C Language? A. An alphabet
A. Bjarne Stroustrup B. A number
B. Dennis Ritchie C. A special symbol other than underscore
C. James A. Gosling D. both (b) and (c)
D. Dr. E.F. Codd 6. Which of the following is allowed in a C Arithmetic instruction
2. C Language developed at _____? A. []
A. AT & T's Bell Laboratories of USA in 1972 B. {}
B. AT & T's Bell Laboratories of USA in 1970 C. ()
C. Sun Microsystems in 1973 D. None of the above
D. Cambridge University in 1972 7. Which of the following shows the correct hierarchy of arithmetic operations in C
3. For 16‐bit compiler allowable range for integer constants is ______ ? A. / + * ‐
A. ‐3.4e38 to 3.4e38 B. * ‐ / +
B. ‐32767 to 32768 C. + ‐ / *
C. ‐32768 to 32767 D. * / + ‐
D. ‐32668 to 32667 8. What is an array?
4. C programs are converted into machine language with the help of A. An array is a collection of variables that are of the dissimilar data type.
A. An Editor B. An array is a collection of variables that are of the same data type.
B. A compiler C. An array is not a collection of variables that are of the same data type.
C. An operating system D. None of the above.
D. None of the above

P a g e 1 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
9. What is right way to Initialization array? 13. Bitwise operators can operate upon?

A. int num[6] = { 2, 4, 12, 5, 45, 5 } ; A. double and chars

B. int n{} = { 2, 4, 12, 5, 45, 5 } ; B. floats and doubles

C. int n{6} = { 2, 4, 12 } ; C. ints and floats

D. int n(6) = { 2, 4, 12, 5, 45, 5 } ; D. ints and chars

10. An array elements are always stored in _________ memory locations. 14. What is C Tokens?

A. Sequential A. The smallest individual units of c program

B. Random B. The basic element recognized by the compiler

C. Sequential and Random C. The largest individual units of program

D. None of the above D. A & B Both

11. What is the right way to access value of structure variable book{ price, page }? 15. What is Keywords?

A. printf("%d%d", book.price, book.page); A. Keywords have some predefine meanings and these meanings can be changed.

B. printf("%d%d", price.book, page.book); B. Keywords have some unknown meanings and these meanings cannot be
changed.
C. printf("%d%d", price::book, page::book);
C. Keywords have some predefine meanings and these meanings cannot be
D. printf("%d%d", price‐>book, page‐>book);
changed.
12. perror( ) function used to ?
D. None of the above
A. Work same as printf()
16. What is constant?
B. prints the error message specified by the compiler
A. Constants have fixed values that do not change during the execution of a
C. prints the garbage value assigned by the compiler program

D. None of the above 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


P a g e 2 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
17. Which is the right way to declare constant in C? 21. What is function?

A. int constant var =10; A. Function is a block of statements that perform some specific task.

B. int const var = 10; B. Function is the fundamental modular unit. A function is usually designed to
perform a
C. const int var = 10;
specific task.
D. B & C Both
C. Function is a block of code that performs a specific task. It has a name and it is
18. Which operators are known as Ternary Operator?
reusable
A. ::, ?
D. All the above
B. ?, :
22. Which one of the following sentences is true ?
C. ?, ;;
A. The body of a while loop is executed at least once.
D. None of the above
B. The body of a do ... while loop is executed at least once.
19. In switch statement, each case instance value must be _______?
C. The body of a do ... while loop is executed zero or more times.
A. Constant
D. A for loop can never be used in place of a while loop.
B. Variable
23. A binary tree with 27 nodes has _______ null branches.
C. Special Symbol
A. 54
D. None of the above
B. 27
20. What is the work of break keyword?
C. 26
A. Halt execution of program
D. None of the above
B. Restart execution of program
24. Which one of the following is not a linear data structure?
C. Exit from loop or switch statement
A. Array
D. None of the above
B. Binary Tree

C. Queue

D. Stack

P a g e 3 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
25. Recursive functions are executed in a? 29. Which of the following data structure is linear type?

A. First In First Out Order A. Strings

B. Load Balancing B. Queue

C. Parallel Fashion C. Lists

D. Last In First Out Order D. All of the above

26. Queue is a _____________ list. 30. The statement printf("%c", 100); will print?

A. LIFO A. prints 100

B. LILO B. print garbage

C. FILO C. prints ASCII equivalent of 100

D. FIFO D. None of the above

27. The statement print f ("%d", 10 ? 0 ? 5 : 1 : 12); will print? 31. The _______ memory allocation function modifies the previous allocated space.

A. 10 A. calloc

B. 0 B. free

C. 12 C. malloc

D. 1 D. realloc

28. To represent hierarchical relationship between elements, which data structure is 32. Number of binary trees formed with 5 nodes are

suitable? A. 30

A. Priority B. 36

B. Tree C. 108

C. Dqueue D. 42

D. All of the above

P a g e 4 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
33. The "C" language is 37. The Default Parameter Passing Mechanism is called as

A. Context free language A. Call by Value

B. Context sensitive language B. Call by Reference

C. Regular language C. Call by Address

D. None of the above D. Call by Name

34. The worst case time complexity of AVL tree is better in comparison to binary 38. What is Dequeue?

search tree for A. Elements can be added from front

A. Search and Insert Operations B. Elements can be added to or removed from either the front or rear

B. Search and Delete Operations C. Elements can be added from rear

C. Insert and Delete Operations D. None of the above

D. Search, Insert and Delete Operations 39. In which linked list last node address is null?

35. In which tree, for every node the height of its left subtree and right subtree A. Doubly linked list

differ almost by one? B. Circular list

A. Binary search tree C. Singly linked list

B. AVL tree D. None of the above

C. Threaded Binary Tree 40. Which is the correct syntax to declare constant pointer?

D. Complete Binary Tree A. int *const constPtr;

36. C is ______ Language? B. *int constant constPtr;

A. Low Level C. const int *constPtr;

B. High Level D. A and C both

C. Assembly Level

D. Machine Level

P a g e 5 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
More TOP C Language Multiple Choice b) error

1. What will be the output of the following arithmetic expression ? c) 1

5+3*2%10‐8*6 d) garbage value

a) ‐37 5. What will be the output of the following statements ?

b) ‐42 int a = 5, b = 2, c = 10, i = a>b

c) ‐32 void main()

d) ‐28 { printf("hello"); main(); }

2. What will be the output of the following statement ? a) 1

int a=10; printf("%d &i",a,10); b) 2

a) error c) infinite number of times

b) 10 d) none of these

c) 10 10 6. What will be output if you will compile and execute the following c code?

d) none of these struct marks{

3. What will be the output of the following statement ? int p:3;

printf("%X%x%ci%x",11,10,'s',12); int c:3;

a) error int m:2;

b) basc };

c) Bas94c void main(){

d) none of these struct marks s={2,‐6,5};

4. What will be the output of the following statements ? printf("%d %d %d",s.p,s.c,s.m);

int a = 4, b = 7,c; c = a = = b; printf("%i",c); }

a) 0

P a g e 6 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
(a) 2 ‐6 5 d) 2

(b) 2 ‐6 1 10. What will be the output of the following program ?

(c) 2 2 1 #include

(d) Compiler error void main()

(e) None of these { int a = 2;

7. What will be the output of the following statements ? switch(a)

int x[4] = {1,2,3}; printf("%d %d %D",x[3],x[2],x[1]); { case 1:

a) 03%D printf("goodbye"); break;

b) 000 case 2:

c) 032 continue;

d) 321 case 3:

8. What will be the output of the following statement ? printf("bye");

printf( 3 + "goodbye"); }

a) goodbye }

b) odbye a) error

c) bye b) goodbye

d) dbye c) bye

9. What will be the output of the following statements ? d) byegoodbye

long int a = scanf("%ld%ld",&a,&a); printf("%ld",a); 11. What will be the output of the following statements ?

a) error int i = 1,j; j=i‐‐‐ ‐2; printf("%d",j);

b) garbage value a) error

c) 0 b) 2

P a g e 7 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
c) 3 a) 1

d) ‐3 b) 2

12. What will be the output of following program ? c) 6

#include d) Error

main() 15. What will be the output of the following statements ?

{ int i = 3;

int x,y = 10; printf("%d%d",i,i++);

x = y * NULL; a) 34

printf("%d",x); b) 43

} c) 44

a) error d) 33

b) 0 16. What will be the output of the following program ?

c) 10 #include

d) garbage value void main()

13. What will be the output of following statements ? {

char x[ ] = "hello hi"; printf("%d%d",sizeof(*x),sizeof(x)); int a = 36, b = 9;

a) 88 printf("%d",a>>a/b‐2);

b) 18 }

c) 29 a) 9

d) 19 b) 7

14. What will be the output of the following statements ? c) 5

int a=5,b=6,c=9,d; d=(ac?1:2):(c>b?6:8)); printf("%d",d); d) none of these

P a g e 8 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
17. int testarray[3][2][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; void main()

What value does testarray[2][1][0] in the sample code above contain? {

a) 11 int s=0;

b) 7 while(s++<10)>

c) 5 # define a 10

d) 9 main()

18. void main() {

{ printf("%d..",a);

int a=10,b=20; foo();

char x=1,y=0; printf("%d",a);

if(a,b,x,y) }

{ void foo()

printf("EXAM"); {

} #undef a

} #define a 50

What is the output? }

a) XAM is printed a) 10..10

b) exam is printed b) 10..50

c) Compiler Error c) Error

d) Nothing is printed d) 0

19. What is the output of the following code?

#include

P a g e 9 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
20. main() {

{ char str[]="S\065AB";

struct printf("\n%d", sizeof(str));

{ }

int i; a) 7

}xyz; b) 6

(*xyz)‐>i=10; c) 5

printf("%d",xyz.i); d) error

} 23. What will be the value of `a` after the following code is executed

What is the output of this program? #define square(x) x*x

a) program will not compile a = square(2+3)

b) 10 a) 25

c) god only knows b) 13

d) address of I c) 11

21.What will happen if in a C program you assign a value to an array element whose d) 10

A. The element will be set to 0. 24. #include

B. The compiler would report an error. void func()

C. The program may crash if some important data gets overwritten. {

D. The array size would appropriately grow. int x = 0;

22. What would be the output of the following program? static int y = 0;

#include x++; y++;

main() printf( "%d ‐‐ %d\n", x, y );

P a g e 10 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
} 25. long factorial (long x)

int main() {

{ ????

func(); return x * factorial(x ‐ 1);

func(); }

return 0; With what do you replace the ???? to make the function shown above return the

} correct answer?

What will the code above print when it is executed? a)

a) if (x == 0) return 0;

1 ‐‐ 1 b)

1 ‐‐ 1 return 1;

b) c)

1 ‐‐ 1 if (x >= 2) return 2;

2 ‐‐ 1 d)

c) if (x <= 1) return 1;

1 ‐‐ 1 26. int y[4] = {6, 7, 8, 9};

2 ‐‐ 2 int *ptr = y + 2; printf("%d\n", ptr[ 1 ] );

d) What is printed when the sample code above is executed?

1 ‐‐ 1 a) 6

1 ‐‐ 2 b) 7

c) 8

d) 9

P a g e 11 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
27. int i = 4; c) i = 9

switch (i) d) i = 10

{ 28. What will be output if you will compile and execute the following c code?

default: ; void main()

case 3: {

i += 5; if(printf("cquestionbank"))

if ( i == 8) printf("I know c");

{ else

i++; printf("I know c++");

if (i == 9) break; }

i *= 2; (a) I know c

} (b) I know c++

i ‐= 4; (c) cquestionbankI know c

break; (d) cquestionbankI know c++

case 8: (e) Compiler error

i += 5; 29.What will be output if you will compile and execute the following c code?

break; #define call(x) #x

} void main(){

printf("i = %d\n", i); printf("%s",call(c/c++));

What will the output of the sample code above be? }

a) i = 5 (a)c

b) i = 8 (b)c++

P a g e 12 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
(c)#c/c++ getch();

(d)c/c++ }

(e)Compiler error (a) 25 25

30. What will be output if you will compile and execute the following c code? (b) 025 0x25

#define message "union is\ (c) 12 42

power of c" (d) 31 19

void main() (e) None of these

{ 32. What will be output if you will compile and execute the following c code?

clrscr(); void main()

printf("%s",message); {

getch(); int i=0;

} if(i==0){

(a) union is power of c i=((5,(i=3)),i=1);

(b) union is power of c printf("%d",i);

(c) union is Power of c }

(d) Compiler error else

(e) None of these printf("equal");

31. What will be output if you will compile and execute the following c code? }

void main(){ (a) 5

int a=25; (b) 3

clrscr(); (c) 1

printf("%o %x",a,a); (d) equal

P a g e 13 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
(e) None of above }

33.What will be output if you will compile and execute the following c code? (a) 3

int extern x; (b) 21

void main() (c) 17

printf("%d",x); (d) 7

x=2; (e) Compiler error

getch(); 35.What will be output if you will compile and execute the following c code?

} void main(){

int x=23; static main;

(a) 0 int x;

(b) 2 x=call(main);

(c) 23 clrscr();

(d) Compiler error printf("%d ",x);

(e) None of these getch();

34.What will be output if you will compile and execute the following c code? }

void main(){ int call(int address){

int a,b; address++;

a=1,3,15; return address;

b=(2,4,6); }

clrscr(); (a) 0

printf("%d ",a+b); (b) 1

getch(); (c) Garbage value

P a g e 14 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
(d) Compiler error //show mouse pointer

(e) None of these i.x.ax=1;

36. What will be output if you will compile and execute the following c code? int86(0x33,&i,&o);

#include "string.h" while(!kbhit()) //its value will false when we hit key in the key board

void main(){ {

clrscr(); i.x.ax=3; //get mouse position

printf("%d %d",sizeof("string"),strlen("string")); x=o.x.cx;

getch(); y=o.x.dx;

} clrscr();

(a) 6 6 printf("(%d , %d)",x,y);

(b) 7 7 delay(250);

(c) 6 7 int86(0x33,&i,&o);

(d) 7 6 }

(e) None of these getch();

37. Write c program which display mouse pointer and position of pointer.(In x }

coordinate, y coordinate)? 38.What will be output if you will compile and execute the following c code?

#include”dos.h” void main(){

#include”stdio.h” int huge*p=(int huge*)0XC0563331;

void main() int huge*q=(int huge*)0xC2551341;

{ *p=200;

union REGS i,o; printf("%d",*q);

int x,y,k; }

P a g e 15 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
(a)0 40.What will be output if you will compile and execute the following c code?

(b)Garbage value void main(){

(c)null if(printf("cquestionbank"))

(d) 200 printf("I know c");

(e)Compiler error else

39.What will be output if you will compile and execute the following c code? printf("I know c++");

struct marks{ }

int p:3; (a) I know c

int c:3; (b) I know c++

int m:2; (c) cquestionbankI know c

}; (d) cquestionbankI know c++

void main(){ (e) Compiler error

struct marks s={2,‐6,5}; 41.What will be output if you will compile and execute the following c code?

printf("%d %d %d",s.p,s.c,s.m); #define call(x) #x

} void main(){

(a) 2 ‐6 5 printf("%s",call(c/c++));

(b) 2 ‐6 1 }

(c) 2 2 1 (a)c

(d) Compiler error (b)c++

(e) None of these (c)#c/c++

(d)c/c++

(e)Compiler error

P a g e 16 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
42. What will be output if you will compile and execute the following c code? (b) 025 0x25

#define message "union is\ (c) 12 42

power of c" (d) 31 19

void main(){ (e) None of these

clrscr(); 44. What will be output if you will compile and execute the following c code?

printf("%s",message); void main(){

getch(); int i=0;

} if(i==0){

(a) union is power of c i=((5,(i=3)),i=1);

(b) union ispower of c printf("%d",i);

(c) union is }

Power of c else

(d) Compiler error printf("equal");

(e) None of these }

43. What will be output if you will compile and execute the following c code? (a) 5

void main(){ (b) 3

int a=25; (c) 1

clrscr(); (d) equal

printf("%o %x",a,a); (e) None of above

getch(); 45.What will be output if you will compile and execute the following c code?

} int extern x;

(a) 25 25 void main()

P a g e 17 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
printf("%d",x); (d) 7

x=2; (e) Compiler error

getch(); 47.What will be output if you will compile and execute the following c code?

} void main(){

int x=23; static main;

(a) 0 int x;

(b) 2 x=call(main);

(c) 23 clrscr();

(d) Compiler error printf("%d ",x);

(e) None of these getch();

46.What will be output if you will compile and execute the following c code? }

void main(){ int call(int address){

int a,b; address++;

a=1,3,15; return address;

b=(2,4,6); }

clrscr(); (a) 0

printf("%d ",a+b); (b) 1

getch(); (c) Garbage value

} (d) Compiler error

(a) 3 (e) None of these

(b) 21

(c) 17

P a g e 18 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
48.What will be output if you will compile and execute the following c code? (d) 200

#include "string.h" (e)Compiler error

void main(){ 50.What will be output if you will compile and execute the following c code?

clrscr(); struct marks{

printf("%d %d",sizeof("string"),strlen("string")); int p:3;

getch(); int c:3;

} int m:2;

(a) 6 6 };

(b) 7 7 void main(){

(c) 6 7 struct marks s={2,‐6,5};

(d) 7 6 printf("%d %d %d",s.p,s.c,s.m);

(e) None of these }

49.What will be output if you will compile and execute the following c code? (a) 2 ‐6 5

void main(){ (b) 2 ‐6 1

int huge*p=(int huge*)0XC0563331; (c) 2 2 1

int huge*q=(int huge*)0xC2551341; (d) Compiler error

*p=200; (e) None of these

printf("%d",*q); 51.What will be output if you will compile and execute the following c code?

} void main(){

(a)0 if(printf("cquestionbank"))

(b)Garbage value printf("I know c");

(c)null else

P a g e 19 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
printf("I know c++"); printf("%s",message);

} getch();

(a) I know c }

(b) I know c++ (a) union is power of c

(c) cquestionbankI know c (b) union ispower of c

(d) cquestionbankI know c++ (c) union is

(e) Compiler error Power of c

52.What will be output if you will compile and execute the following c code? (d) Compiler error

#define call(x) #x (e) None of these

void main(){ 54. What will be output if you will compile and execute the following c code?

printf("%s",call(c/c++)); void main(){

} int a=25;

(a)c clrscr();

(b)c++ printf("%o %x",a,a);

(c)#c/c++ getch();

(d)c/c++ }

(e)Compiler error (a) 25 25

53. What will be output if you will compile and execute the following c code? (b) 025 0x25

#define message "union is\ (c) 12 42

power of c" (d) 31 19

void main(){ (e) None of these

clrscr();

P a g e 20 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
55.What will be output if you will compile and execute the following c code? int x=23;

void main(){ (a) 0

int i=0; (b) 2

if(i==0){ (c) 23

i=((5,(i=3)),i=1); (d) Compiler error

printf("%d",i); (e) None of these

} 57.What will be output if you will compile and execute the following c code?

else void main(){

printf("equal"); int a,b;

} a=1,3,15;

(a) 5 b=(2,4,6);

(b) 3 clrscr();

(c) 1 printf("%d ",a+b);

(d) equal getch();

(e) None of above }

56.What will be output if you will compile and execute the following c code? (a) 3

int extern x; (b) 21

void main() (c) 17

printf("%d",x); (d) 7

x=2; (e) Compiler error

getch();

P a g e 21 | 22
Worksheet/programming/IUSTY/HND/NGAKAM
58.What will be output if you will compile and execute the following c code? printf("%d %d",sizeof("string"),strlen("string"));

void main(){ getch();

static main; }

int x; (a) 6 6

x=call(main); (b) 7 7

clrscr(); (c) 6 7

printf("%d ",x); (d) 7 6

getch(); (e) None of these

} 60.What will be output if you will compile and execute the following c code?

int call(int address){ void main(){

address++; int huge*p=(int huge*)0XC0563331;

return address; int huge*q=(int huge*)0xC2551341;

} *p=200;

(a) 0 printf("%d",*q);

(b) 1 }

(c) Garbage value (a)0

(d) Compiler error (b)Garbage value

(e) None of these (c)null

59.What will be output if you will compile and execute the following c code? (d) 200

#include "string.h" (e)Compiler error

void main(){

clrscr();

P a g e 22 | 22

You might also like