Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

what will be the result of the following program ? char *gxxx() { static char xxx[1024]; return xxx; } main() { char *g="string"; strcpy(gxxx(),g); g = gxxx(); strcpy(g,"oldstring"); printf("The string is : %s",gxxx()); } a) The string is : string b) The string is :Oldstring c) Run time error/Core dump d) Syntax error during compilation e) None of these

2 Answers   IBM,


Once I have used freopen, how can I get the original stdout (or stdin) back?

0 Answers  


How can I recover the file name given an open stream or file descriptor?

0 Answers  


in malloc and calloc which one is fast and why?

1 Answers  


What is this infamous null pointer, anyway?

0 Answers  


What is the best way to comment out a section of code that contains comments?

0 Answers  


What is the relation between # and include<stdio.h>

5 Answers   HCL,


write a program that eliminates the value of mathematical constant e by using the formula e=1+1/1!+1/2!+1/3!+

1 Answers   Reliance,


Can a pointer be null?

0 Answers  


What is pragma in c?

0 Answers  


Why string is used in c?

0 Answers  


where are auto variables stored? What are the characteristics of an auto variable?

0 Answers  


Categories