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" ) ; } }

14th Oct 2019, 7:15 PM
Rehman Khan
Rehman Khan - avatar
1 Antwort
+ 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 : )
14th Oct 2019, 7:30 PM
Ipang