Thursday, August 19, 2010

C Programming - display numbers in ascending and descending orders

#include<stdio.h>
#include<conio.h>
main()
{
int i;
clrscr();
printf("\n numbers is ascending order :");
for(i=1;i<=10;++i)
{
printf("%3d",i);

}
printf("\n numbers in descending order:");
for(i=10;i>0;i--)
{
printf("%3d",i);
}
getch();
}

output:-
numbers in ascending order :1 2 3 4 5 6 7 8 9 10
numbers in descending order:10 9 8 7 6 5 4 3 2 1

No comments:

Post a Comment