consider the following program sigment
int n,sum=1;
switch(n) {
case 2:sum=sum+2;
case 3:sum*=2;
break;
default:sum=0;}
if n=2, what is the value of sum
a.0
b.6
c.3
d.none

Answers were Sorted based on User's Feedback



consider the following program sigment int n,sum=1; switch(n) { case 2:sum=sum+2; ca..

Answer / guest

6

Is This Answer Correct ?    19 Yes 0 No

consider the following program sigment int n,sum=1; switch(n) { case 2:sum=sum+2; ca..

Answer / mytri

6

Is This Answer Correct ?    12 Yes 0 No

consider the following program sigment int n,sum=1; switch(n) { case 2:sum=sum+2; ca..

Answer / manishsoni

# define prod(a,b) a*b
main()
{
int n=2,sum=1; //here given n=2 so
switch(n) //switch(2)
{
case 2: //encounter this case 2;
sum=sum+2; //add sum=1+2;sum=3
case 3: //here no break statement so case
// 3 is checked by this and
// remained that sum=3;
sum*=2; //so sum =3*2;sum=6
break; //here switch is break and sum=6;
default: //default is don't check ;
sum=0;
}
printf("%d",sum); //so print sum=6;
getch();
}
by manish soni MCA first sem (by rawatsar);

Is This Answer Correct ?    5 Yes 0 No

consider the following program sigment int n,sum=1; switch(n) { case 2:sum=sum+2; ca..

Answer / krishna

answer is c 3

Is This Answer Correct ?    2 Yes 2 No

consider the following program sigment int n,sum=1; switch(n) { case 2:sum=sum+2; ca..

Answer / mahesh

b is answer

Is This Answer Correct ?    0 Yes 0 No

consider the following program sigment int n,sum=1; switch(n) { case 2:sum=sum+2; ca..

Answer / sivasankar.a

the answer is d)none because there in no break statement

Is This Answer Correct ?    1 Yes 7 No

consider the following program sigment int n,sum=1; switch(n) { case 2:sum=sum+2; ca..

Answer / roopa

The anser is d i.e. NONE.
Case 2 does not have the break statement.
so sum becomes 8

Is This Answer Correct ?    2 Yes 13 No

Post New Answer

More C Interview Questions

int i =10 main() { int i =20,n; for(n=0;n<=i;) { int i=10 i++; } printf("%d", i);

6 Answers   HCL, Octal, SW,


How is a null pointer different from a dangling pointer?

0 Answers  


which one of follwoing will read a character from keyboard and store in c a)c=getc() b)c=getchar() c)c=getchar(stdin) d)getc(&c) e)none

7 Answers   Trident,


what are the advantages & disadvantages of unions?

2 Answers  


what is d pitfalls of registers variables

3 Answers   TCS,






what is the difference between getch() and getche()?

7 Answers   Infosys,


i=10,j=20 j=i,j?(i,j)?i:j:j print i,j

1 Answers   CSC,


for(i=0;i=printf("Hello");i++); printf("Hello"); how many times how will be printed?????????

8 Answers  


a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler

0 Answers  


x=y=z=1 z=++x||++y&&++z Printf("%%%d";xyz) what is the values of x,y and z?????

3 Answers  


main() { int a,b; printf("%d,%d",scanf("%d%d",&a,&b)); } => do u mean above program's output... =>output will be:2,whatever you enter value for b. =>because scanf is a library fn which will return how many arguements it processes, and second value you are right mr.Satya but i found my self unable to understand that for the first time scanf returns the no of successful matches but how for the second time it returns the value of 'b'.while a function should return the same 'r' value every time.

1 Answers   Cisco,


What are the advantages and disadvantages of c language?

0 Answers  


Categories