0
How to print out odd numbers from 0-50 using while loop
3 Answers
+ 6
int x=1;
while(x<50) {
cout<<x<<endl;
x+=2;
}
+ 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).
+ 2
int i = 0;
while (i < 25) cout << 1+2*i++ << " ";