Write a C program to print numbers from m to n (where n > m)

3.B) Write a C program to print numbers from m to n. (where n > m)

Answer:-

#include<stdio.h>
#include<conio.h>
void main()
{
 int i,n,m;  /* i for loop counter, m is lower limit, n for lower limit */
 clrscr();
 printf("\n Enter lower limit and upper limit");
 scanf("%d%d", &m, &n);
 printf("\n Numbers from %d to %d are \n", m, n);
 for(i=m; i<=n; i++)
     printf("%5d",i);
getch();
}


  Output:
  Enter lower limit and upper limit
  10 20
  Numbers from 10 to 20 are 
  10 11 12 13 14 15 16 17 18 19 20

Leave a Reply

Your email address will not be published. Required fields are marked *