- 2
Anyone help with how to write a c language that generates odd numbers from 250 to 850 using the for statement.
4 Answers
+ 3
Since the loop begins with an even number 250, you first add 1 to it so it begins from 251, an odd number. Then you can increment the number by 2 for each loop round. The third section of loop definition allows you to do this.
+ 2
Khalid Zak If you show your efforts then ofcourse we can help.
Hint:-
Just check in loop (num % 2 == 1) for odd numbers.
+ 1
Ofcourse but show your code here
+ 1
#include <stdio.h>
int main() {
for (int i = 251; i < 850; i=i+2) {
printf("%d\n", i);
}
return 0;
}
... should work