In this example, a for loop is set up with values of loop variable num from m to n. The if statement is executed for each value of num and if nums an odd number (num%2 equals 1), it is printed using the printf statement. The output of this code is given below for m = 20 and n = 40.
#include<stdio.h> void main() { int num,m =20,n=40; clrscr(); printf("Print Odd Numbers in a given range m to n:\n"); for (num = m; num <= n; num++) { if (num % 2 == 1) printf ("%d ", num); } getch(); }