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
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 |
Answer / sivasankar.a
the answer is d)none because there in no break statement
| Is This Answer Correct ? | 1 Yes | 7 No |
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 |
Are pointers integers in c?
write a programming in c language, 1 3 5 7 9 11
What are linker error?
Can u please send me the exam pattern and also Previous papers to javed123go@gmail.com
1)what are limitations for recursive function? 2)write a program to read a text file and count the number of characters in the text file
Write a program to print fibonacci series using recursion?
What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?
How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters?
pgm to find middle element of linklist(in efficent manner)
plz answer..... a program that reads non-negative integer and computes and prints its factorial
what is the output for this question: main() { int i=1; printf("%d%d%d",i,i++,++i); }
how we do lcm of two no using c simple if while or for statement