+ 2

Can I use comparasion inside cases in c language? My code doesn't work!

https://code.sololearn.com/cEVU8X2ElFTo/?ref=app

29th Jan 2018, 11:54 AM
Samah Alghafri
Samah Alghafri - avatar
9 Answers
+ 6
You want to use if statements for conditional operations (ex. age >= 40). A switch works like: switch(age){ case 40: case 45: case 50: et cetera } https://code.sololearn.com/cDGcG8QDFoxY/?ref=app Check out this code, it helps clarify what you may want
29th Jan 2018, 11:57 AM
J.G.
J.G. - avatar
+ 4
also insted of comparision I can use range num like this👇 case 100 ... 200 :
29th Jan 2018, 12:43 PM
Samah Alghafri
Samah Alghafri - avatar
+ 4
exactly, thanx🌹
29th Jan 2018, 12:54 PM
Samah Alghafri
Samah Alghafri - avatar
+ 3
Than if I want to use swich I must write each single age number ? no other way in swich?
29th Jan 2018, 12:05 PM
Samah Alghafri
Samah Alghafri - avatar
+ 2
I got it now thank you 🌹
29th Jan 2018, 12:07 PM
Samah Alghafri
Samah Alghafri - avatar
+ 2
yup it depends on what you want ,all cases works 👍
29th Jan 2018, 12:46 PM
Yahya Al-saidi
Yahya Al-saidi - avatar
+ 2
ur welcome 🌹
29th Jan 2018, 12:55 PM
Yahya Al-saidi
Yahya Al-saidi - avatar
+ 1
if you want a specific age you need to use switch case ,else you can use if-else case
29th Jan 2018, 12:25 PM
Yahya Al-saidi
Yahya Al-saidi - avatar