edited by
351 views
0 votes
0 votes

Spot the error(s) in this code snippet :

int n=2;   // Line 1
switch(n)
{
case 1.5:
printf( "gate");
break;
case 2:
printf( "overflow");
break;
case 'A':
printf("gateoverflow");
}         // Line 12

The error(s) is in line number _____.

edited by

1 Answer

Best answer
1 votes
1 votes
In line number 4, case 1.5 is invalid,the value in case statement is always integer.
selected by
Answer:

Related questions

0 votes
0 votes
0 answers
1
Bikram asked May 14, 2017
196 views
#include <stdio.h int counter(int i) { static int count = 0; count = count + i; return count; } int main() { int i, j; for (i = 0; i <= 5; i++) j = counter(i); printf ("%...
1 votes
1 votes
1 answer
2
Bikram asked May 14, 2017
291 views
What is the output of the following program?#include <stdio.h int main() { int a = 0; switch(a) { default: a = 4; case 6: a ; case 5: a = a+1; case 1: a = a-1; } printf("...
7 votes
7 votes
2 answers
3
Bikram asked May 14, 2017
538 views
What is the output of the following code snippet? #include <stdio.h int main() { char c=125; c=c+10; printf("%d",c); return 0; }
2 votes
2 votes
1 answer
4
Bikram asked May 14, 2017
190 views
The output of this code snippet is :#include <stdio.h #define x 4+1 int main() { int i; i = x*x*x; printf("%d",i); return 0; }