- 2

Anyone help with how to write a c language that generates odd numbers from 250 to 850 using the for statement.

5th Dec 2020, 8:36 AM
Khalid Zak
Khalid Zak - avatar
4 odpowiedzi
+ 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.
5th Dec 2020, 8:58 AM
Ipang
+ 2
Khalid Zak If you show your efforts then ofcourse we can help. Hint:- Just check in loop (num % 2 == 1) for odd numbers.
5th Dec 2020, 8:52 AM
A͢J
A͢J - avatar
+ 1
Ofcourse but show your code here
5th Dec 2020, 8:42 AM
Sâñtôsh
Sâñtôsh - avatar
+ 1
#include <stdio.h> int main() { for (int i = 251; i < 850; i=i+2) { printf("%d\n", i); } return 0; } ... should work
6th Dec 2020, 12:14 AM
Gizmo-Lang
Gizmo-Lang - avatar