+ 1
How to set limit in while loop. Eg.while (20<num<30)?
#include <iostream> using namespace std; int main() { int num; cin>>num; while(10<num<20) { cout<<"number:"<<num<<endl; num++; } return 0; } I've tried this code but whenever I put any number output is showing unlimited numbers..?
1 Answer
+ 6
You must use a composite boolean operation: instead of
10<num<20
try
num>10 && num<20