Joa It Post Code - 965 C Programming Important Questions and Answers Set - 1

POOJA GUPTA
0

 

Joa It Post Code - 965 C Programming Important Questions and Answers Set - 1

C Programming Important Questions and Answers Set - 1


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

5+3*2%10-8*6

A. -37

B. -42

C. -32

D. -28

Answer: A. -37


2. What will be the output of the following statement ?

int a=10; printf(“%d &i”,a,10);

A. error

B. 10

C. 10 10

D. none of these

Answer: D. none of these


3. What will be the output of the following statement ?

printf(“%X%x%ci%x”,11,10,’s’,12);

A. error

B. basc

C. Bas94c

D. none of these

Answer: B. basc


4. What will be the output of the following statements ?

int a = 4, b = 7,c; c = a = = b; printf(“%i”,C.;

A. 0

B. error

C. 1

D. garbage value

Answer: A. 0


5. What will be the output of the following statements ?

int a = 5, b = 2, c = 10, i = a>b

void main()

{ printf(“hello”); main(); }

A. 1

B. 2

C. infinite number of times

D. none of these

Answer: C. infinite number of times


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. Compiler error


7. What will be the output of the following statements ?

int x[4] = {1,2,3}; printf(“%d %d

%D”,x[3],x[2],x[1]);

A. 03%D

B. 000

C. 032

D. 321

Answer: C. 032


8. What will be the output of the following statement ?

printf( 3 + “goodbye”);

A. goodbye

B. odbye

C. bye

D. dbye

Answer: D. dbye


9. What will be the output of the following statements ?

long int a = scanf(“%ld%ld”,&a,&A.;

printf(“%ld”,A.;

A. error

B. garbage value

C. 0

D. 2

Answer: B. garbage value


10. What will be the output of the following program ?

#include

void main()

{ int a = 2;

switchA. { case 1:

printf(“goodbye”); break;

case 2:

continue;

case 3:

printf(“bye”);

}

}

A. error

B. goodbye

C. bye

D. byegoodbye

Answer: A. error


11. What will be the output of the following statements ?

int i = 1,j; j=i— -2; printf(“%d”,j);

A. error

B. 2

C. 3

D. -3

Answer: C. 3


12. What will be the output of following

program ?

#include

main()

{

int x,y = 10;

x = y * NULL;

printf(“%d”,x);

}

A. error

B. 0

C. 10

D. garbage value

Answer: B. 0


13. What will be the output of following

statements ?

char x[ ] = “hello hi”;

printf(“%d%d”,sizeof(*x),sizeof(x));

A. 88

B. 18

C. 29

D. 19

Answer: D. 19


14. What will be the output of the following statements ?

int a=5,b=6,c=9,d; d=(ac?1:2):(c>b?6:8));

printf(“%d”,D.;

A. 1

B. 2

C. 6

D. Error

Answer: D. Error


15. What will be the output of the following statements ?

int i = 3;

printf(“%d%d”,i,i++);

A. 34

B. 43

C. 44

D. 33

Answer: B. 34


16. What will be the output of the following program ?

#include

void main()

{

int a = 36, b = 9;

printf(“%d”,a>>a/b-2);

}

A. 9

B. 7

C. 5

D. none of these

Answer: A. 9



17. int testarray[3][2][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

What value does testarray [2][1][0] in the

sample code above contain?

A. 11

B. 7

C. 5

D. 9

Answer: A. 11


18. void main()

{

int a=10,b=20;

char x=1,y=0;

if(a,b,x,y)

{

printf(“EXAM”);

}

}

What is the output?

A. XAM is printed

B. exam is printed

C. Compiler Error

D. Nothing is printed

Answer: D. nothing is printed


19. What is the output of the following

code?

#include

void main()

{

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. Error


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

D. address of I

Answer: B. 10






Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Post a Comment (0)
To Top