0

Write a program to print all the odd numbers from 50 to 120 only by using C programming.

9th Jan 2021, 3:10 AM
Joel Ashish
Joel Ashish - avatar
6 Antworten
+ 2
Just a little suggestion: Use a for loop where i starts from 50 and ends in 120 .Then give a if statement to find the odd number from i and print it.
9th Jan 2021, 3:59 AM
The future is now thanks to science
The future is now thanks to science - avatar
+ 2
for(i=50;i<=120;i++) { if(i%2==1) printf("%d",i); }
10th Jan 2021, 11:04 AM
Swaya
+ 1
Pls show us your attempt! We will help you if you have any bugs in your code😊😊
9th Jan 2021, 3:51 AM
Steve Sajeev
Steve Sajeev - avatar
+ 1
The main part of this can be done minimally by two statements: a for() loop statement and a printf() statement. Have the for() loop initialize its integer loop counter to the first odd number in the range: 51. Define a loop condition that tests for the counter being less than 120. Add an update expression that increments the loop counter by 2. That will make the loop counter skip even numbers and hold odd numbers only. Inside the loop place a printf() statement that prints the loop counter's integer value.
9th Jan 2021, 4:52 AM
Brian
Brian - avatar