Can we give a value range such as 0<x<50? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can we give a value range such as 0<x<50?

can we write like if(0<x<50) cout<<"pass";

1st Mar 2017, 5:04 PM
Nikhil Philip
Nikhil Philip - avatar
2 Answers
+ 4
You can avoid using nested if's, if you use a composite boolean expression: if (x>0 && x<50) cout<<"pass";
1st Mar 2017, 5:37 PM
Álvaro
0
No this is incorrect in c++ And allowed in python In c++ if you want to give a value range you have to use nested 'if '.... if (x >0) { if (x <50) cout << x << "is between 0 and 50 "; }
1st Mar 2017, 5:18 PM
Prarthana patil