This code segment-first accepts a range of values in variables m and n, both of type int. The variable num, also of type int, is used as the loop variable. It assumes values from m to n. For each value of loop variable num, the printf statement within the for loop executes.
Thus, all the numbers from m to n printed. Observe the space character after the %d format in the printf statement. It causes a space to print after each value of num—the output given below.
1 2 3 4 5 6 7 8 9 10 11 | #include<stdio.h> void main() { int num,m,n; clrscr(); printf ( "Enter range (m, n ) : " ) ; scanf ( "%d %d" , &m, &n); for (num = m; num <= n; num++) { printf ( "%d " , num); } getch(); } |