0
What is the error in above code
#include<stdio.h> main( ) { int temp ; scanf ( "%d", &temp ) ; switch ( temp ) { case ( temp <= 20 ) : printf ( "\nOoooooohhhh! Damn cool!" ) ; case ( temp > 20 && temp <= 30 ) : printf ( "\nRain rain here again!" ) ; case ( temp > 30 && temp <= 40 ) : printf ( "\nWish I am on Everest" ) ; default : printf ( "\nGood old nagpur weather" ) ; } }
1 Answer
+ 1
switch cases in C doesn't support value ranges as it does in `if` statement. For this particular conditional checking, I would suggest to use `if` statement instead : )