0

How to print out odd numbers from 0-50 using while loop

25th Apr 2017, 8:51 AM
jesse
3 ответов
+ 6
int x=1; while(x<50) { cout<<x<<endl; x+=2; }
25th Apr 2017, 8:55 AM
Mario L.
Mario L. - avatar
+ 6
int i =0; while(i<=50){ if (i%2!=0){ cout<<i<<endl; } i=i+1; } Check out the tutorial as well. I believe it is very well explained there. Many ways to perform this task. @Mario's is a quicker one (and more elegant).
25th Apr 2017, 8:59 AM
Billy Tsouvalas
+ 2
int i = 0; while (i < 25) cout << 1+2*i++ << " ";
25th Apr 2017, 9:52 AM
Toky R.
Toky R. - avatar