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
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 |
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 |
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 |
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 |
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 |
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 |
How can a program be made to print the name of a source file where an error occurs?
WHAT IS MAXIMUM SIZE OF AN ARRAY IN C LANGUAGE?
8 Answers Carphone Warehouse, IBM, SAS,
What is the use of f in c?
What is the condition that is applied with ?: Operator?
What is the difference between macros and inline functions?
What are global variables and how do you declare them?
What is the heap in c?
What is property type c?
What is the advantage of c?
c program to add and delete an element from circular queue using array
Differentiate between new and malloc(), delete and free() ?
Where register variables are stored in c?