what is the output of the program and explain why??
#include<stdio.h>

void main ( )

{

int k=4,j=0:

switch (k)

{

case 3;

j=300;

case 4:

j=400:

case 5:

j=500;

}

printf (ā€œ%d\nā€,j);

}

Answers were Sorted based on User's Feedback



what is the output of the program and explain why?? #include<stdio.h> void main ( ) { ..

Answer / tejal

k=4 bcoz of this control directly switch to case 4 ,now i
holds the value 400 there is no any break statement after
case 4 so now control goes to case 5 and assign value of i
as 500 .now control comes out of the loop and print the
valus of i i.e. 500.

Is This Answer Correct ?    0 Yes 0 No

what is the output of the program and explain why?? #include<stdio.h> void main ( ) { ..

Answer / sathish

400

Is This Answer Correct ?    4 Yes 5 No

what is the output of the program and explain why?? #include<stdio.h> void main ( ) { ..

Answer / gollapally

400
500

Is This Answer Correct ?    2 Yes 7 No

what is the output of the program and explain why?? #include<stdio.h> void main ( ) { ..

Answer / ramprabha

0

Is This Answer Correct ?    3 Yes 9 No

Post New Answer

More C Interview Questions

What is pointers in c?

0 Answers  


int main() { int days; printf("enter days you are late"); scanf("%d",days); if (days<=5) printf("5o paisa fine"); if (days<=10&&days>=6) printf("1rs fine"); if(days>10) printf("10 rs fine"); if(days=30) printf("membership cancelled"); return 0; } tell me whats wrong in this program? is it right?

2 Answers  


what is recursion in C

0 Answers   Cap Gemini,


What is sizeof array in c?

0 Answers  


Explain what are the advantages and disadvantages of a heap?

0 Answers  






how the compiler treats any volatile variable?Explain with example.

1 Answers   Tata Elxsi,


What is use of integral promotions in c?

0 Answers  


Find the O/p of the following struct node { char *name; int num; }; int main() { struct node s1={"Harry",1331}; struct node s2=s1; if(s1==s2) printf("Same"); else printf("Diff"); }

1 Answers  


given the piece of code int a[50]; int *pa; pa=a; to access the 6th element of the array which of the following is incorrect? a.*(a+5) b.a[5] c.pa[5] d.*(*pa + 5)

6 Answers   amu, TCS,


How we can write a value to an address using macro..?

0 Answers   Tata Elxsi,


What are the properties of union in c?

0 Answers  


I came across some code that puts a (void) cast before each call to printf. Why?

0 Answers  


Categories