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 / ramprabha

500

Is This Answer Correct ?    15 Yes 6 No

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

Answer / prasad

500

Is This Answer Correct ?    9 Yes 0 No

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

Answer / prashanth

the answer is 500 as break is not mentioned it goes to case
5 from case4 so value of j=500

Is This Answer Correct ?    7 Yes 1 No

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

Answer / avinash

because there us no break statement after case

Is This Answer Correct ?    6 Yes 0 No

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

Answer / gouse mohiddin

500

Is This Answer Correct ?    6 Yes 1 No

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

Answer / ashutosh tiwari

compiler error!
after case 3 there is semicolon & j=400 also ended with
semicolon

Is This Answer Correct ?    6 Yes 2 No

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

Answer / kalyan chukka

Ans is 500 i dont know y it printing 500 u mention k=3 or 4
or 5 any no it prints only 500

Is This Answer Correct ?    3 Yes 0 No

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

Answer / amik

the answer will b 500 becoz...when first k = 4 is
executing...the value of j is 400 den thr is no break
statement...so it will continue..nd at the end of the
switch..j will contain or retain.. the value 500

Is This Answer Correct ?    3 Yes 0 No

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

Answer / vijay r15

error
Becoz
j=0: j=400: // in these : should be replaced by ;
In case 3; // in this ; should be replaced by :

After correcting this the op is 500 becoz there is no break statement
Ans 500

Dbtfull guys mail to raj.vijay55@gmail.com

Is This Answer Correct ?    2 Yes 0 No

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

Answer / aswini

as there is no semicolon,uit will execute all the case
statements and j will be assigned as 500.
hence it will print 500..

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C Interview Questions

what are brk, sbrk?

1 Answers   Oracle,


Do character constants represent numerical values?

0 Answers  


write a program to input 10 strings and compare without using strcmp() function. If the character of one string matches with the characters of another string , sort them and make it a single string ??? example:- str1="Aakash" st2="Himanshu" str="Uday" output:- Aakashimanshuday (please post the answer as quickly as possible)

0 Answers   Google,


Write a program to swap two numbers without using third variable?

0 Answers  


What is a floating point in c?

0 Answers  


What do you mean by recursion in c?

0 Answers  


Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].

0 Answers  


for (i <= 5 && i >= -1;++i; i > 0) { printf("%d ", i); }

1 Answers  


What is Heap?

3 Answers  


what is the c.

3 Answers   IBM, TCS,


Explain the use of #pragma exit?

0 Answers  


if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0

0 Answers  


Categories