Tuesday, October 14, 2014

9teen sample C programs

CHECK OUT HERE AND FIND AMAZING STUFF HERE

Visit this link for online earning really working Simple to get in and earn i assure you that

1. What will be output when you will execute following c code?

#include<stdio.h>void main(){int a=5,b=10,c=1;if(a&&b>c){printf("your own blog");}else{break;}}

Choose all that apply:

(A) your own blog(B) It will print nothing(C) Run time error(D) Compilation error
(E) None of the above

Explanation:Keyword break is not syntactical part of if-else statement. So we cannot use break keyword in if-else statement. This keyword can be use in case of loop or switch case statement. Hence when you will compile above code compiler will show an error message: Misplaced break.

2.

What will be output when you will execute following c code?

#define PRINT printf("StarDust");printf(" SHOOTER");#include<stdio.h>void main(){int x=1;if(x--)PRINTelseprintf("The Shawshank Redemption");}

Choose all that apply:

(A) StarsDust SHOOTER(B) The Shawshank Redemption(C) Warning: Condition is always true(D) Warning: Condition is always false





3.

What will be output when you will execute following c code?

#define True 5==5#include<stdio.h>void main(){if(.001-0.1f)printf("David Beckham");else if(True)printf("Ronaldinho");elseprintf("Cristiano Ronaldo");}

Choose all that apply:

(A) David Beckham(B) Ronaldinho
(C) Cristiano Ronaldo(D) Warning: Condition is always true(E) Warning: Unreachable code





4.

What will be output when you will execute following c code?

#include<stdio.h>void main(){int a=100;if(a>10)printf("M.S. Dhoni");else if(a>20)printf("M.E.K Hussey");else if(a>30)printf("A.B. de villiers");}

Choose all that apply:

(A) M.S. Dhoni(B) A.B. de villiers(C) M.S Dhoni M.E.K Hussey A.B. de Villiers(D) Compilation error: More than one conditions are true(E) None of the above




5.

What will be output when you will execute following c code?

#include<stdio.h>void main(){int x=-1,y=-1;if(++x=++y)printf("R.T. Ponting");elseprintf("C.H. Gayle");}

Choose all that apply:

(A) R.T Ponting(B) C.H. Gayle(C) Warning: x and y are assigned a value that is never used(D) Warning: Condition is always true(E) Compilation error





6.

What will be output when you will execute following c code?

#include<stdio.h>void main(){if(sizeof(void))printf("M. Muralilidaran");elseprintf("Harbhajan Singh");}

Choose all that apply:

(A) M. Muralilidaran(B) Harbhajan Singh(C) Warning: Condition is always false(D) Compilation Error(E) None of the above







7.

What will be output when you will execute following c code?

#include<stdio.h>void main(){int m=5,n=10,q=20;if(q/n*m)printf("William Gates");elseprintf(" Warren Buffet");printf(" Carlos Slim Helu");}

Choose all that apply:(A) William Gates(B) Warren Buffet Carlos Slim Helu(C) Run time error(D) Compilation error




8.

What will be output when you will execute following c code?

#include<stdio.h>void main(){if(!printf("Mukesh Ambani"))if(printf(" Lakashmi Mittal"));}

Choose all that apply:

(A) Mukesh Ambani(B) Lakashmi Mittal(C) It will print nothing(D) Mukesh Ambani Lakashmi Mittal(E) Compilation error: if statement without body



9.

What will be output when you will execute following c code?

#include<stdio.h>void main(){if("ABC") printf("Barack Obama\n");if(-1) printf("Hu Jintao\n");if(.92L) printf("Nicolas Sarkozy\n");if(0) printf("Ben Bernanke\n");if('W') printf("Vladimir Putin\n");}

Choose all that apply:

(A) It will print nothing(B) Barack ObamaHu JintaoNicolas SarkozyVladimir Putin(C) Barack ObamaHu JintaoNicolas SarkozyBen BernankeVladimir Putin
(D) Hu JintaoNicolas SarkozyVladimir Putin (E) Compilation error



10.

What will be output when you will execute following c code?

#include<stdio.h>void main(){if(0xA)if(052)if('\xeb')if('\012')printf("Tom hanks");else;else;else;else;}

Choose all that apply:

(A) Tom hanks(B) Compilation error: Misplaced else(C) Compilation error: If without any body(D) Compilation error: Undefined symbol(E) Warning: Condition is always true



11.

What will be output when you will execute following c code?

#include<stdio.h>void main(){int a=10;if(printf("%d",a>=10)-10)for(;;)break;else;}

Choose all that apply:

(A) It will print nothing(B) 0(C) 1(D) Compilation error: Misplaced else(E) Infinite loop



12.

What will be output when you will execute following c code?

#include<stdio.h>void main(){int a=5,b=10;if(++a||++b)printf("%d %d",a,b);elseprintf("John Terry");}

Choose all that apply:

(A) 5 10(B) 6 11(C) 6 10(D) 5 11(E) John Terry

Explanation:

Consider the following expression:++a || ++b

In this expression || is Logical OR operator. Two important properties of this operator are:Property 1:(Expression1) || (Expression2)|| operator returns 0 if and only if both expressions return a zero otherwise it || operator returns 1.

Property 2:

To optimize the execution time there is rule, Expression2 will only evaluate if and only if Expression1 return zero.

In this program initial value of a is 5. So ++a will be 6. Since ++a is returning a non-zero so ++b will not execute and if condition will be true and if clause will be executed.

13.

What will be output when you will execute following c code?

#include<stdio.h>void main(){static int i;for(;;)if(i+++"The Matrix")printf("Memento");elsebreak;}

Choose all that apply:

(A) It will print Memento at one time(B) It will print Memento at three times(C) It will print Memento at ten times(D) It will print Memento at infinite times(E) Compilation error: Unknown operator +++





14.

What will be output when you will execute following c code?

#include<stdio.h>void main(){int x=1;if(x--)printf("The Godfather");--x;elseprintf("%d",x);}

Choose all that apply:

(A) The Godfather(B) 1(C) 0(D) Compilation error(E) None of the above






15.

What will be output when you will execute following c code?

#include<stdio.h>void main(){if('\0');else if(NULL)printf("Whats_ur_RASHI??Yeah to bata DO");else;}

Choose all that apply:

(A) Whats_ur_RASHI??Yeah to bata DO(B) It will print nothing(C) Warning: Condition is always true(D) Warning: Unreachable code(E) Compilation error: if statement without any body





16.

What will be output when you will execute following c code?

#include<stdio.h>void main(){int a=5,b=10;if(a<++a||b<++b)printf("%d %d",a,b);elseprintf("John Terry");}

Choose all that apply:

(A) 5 10(B) 6 11(C) 6 10(D) Compilation error(E) John Terry





17.

What will be output when you will execute following c code?

#include<stdio.h>void main(){int x=1,y=2;if(--x && --y)printf("x=%d y=%d",x,y);elseprintf("%d %d",x,y);}

Choose all that apply:

(A) 1 2(B) x=1 y=2(C) 0 2(D) x=0 y=1(E) 0 1






18.

What will be output when you will execute following c code?

#include<stdio.h>void main(){signed int a=-1;unsigned int b=-1u;if(a==b)printf("LOTS OF LOVE");elseprintf("LAUGH OUT LOUD");}

Choose all that apply:

(A) LOTS OF LOVE(B) LAUGH OUT LOUD(C) Compilation error: Cannot compare signed number with unsigned number(D) Compilation error: Undefined symbol -1u(E) Warning: Illegal operation

19.

What will be output when you will execute following c code?

#include<stdio.h>void main(){char cc=256;char *ptrr="Lenny";if(cc==0)
while(!cc)if(*ptrr++)printf("%+u",cc);elsebreak;}

Choose all that apply:

(A) +256+256+256+256(B) 00000(C) +0+0+0+0(D) It will print +256 at infinite times(E) Compilation error



20.

What will be output when you will execute following c code?

#include<stdio.h>void main(){int a=2;if(a--,--a,a)printf("MAMA’s BOY");elseprintf("I LUV MY DAD");}

Choose all that apply:

(A) MAMA’s BOY(B) I LUV MY DAD(C) Run time error(D) Compilation error: Multiple parameters in if statement(E) None of the above

No comments:

Post a Comment