Thursday, July 28, 2011

Display whole numbers between two given numbers

#include<stdio.h>
void main()

{
int i,j,num,k,initial;
clrscr();
printf("Enter the limit :  ");
scanf("%d%d",&j,&k);
if(j>k)
{
num=j-k;
initial=k;
}
else
{
num=k-j;
initial=j;
}
for(i=0;i<=num;i++)
 {
 printf("%d\t",initial);
 initial+=1;
 }
getch();
}

0 comments:

Post a Comment