print 1,10,2,9,3,8,4,7,5,6...

/* print 1,10,2,9,3,8,4,7,5,6 /*

#include
#include
void main()
{
int j,i=1;
clrscr();
printf("enter number: ");
scanf("%d",&j);
for(i=1;i<=j;i++,j--)
{
printf(" %d %d",i,j);

}
getch();
}

2 comments:

Unknown said...

The Above program will terminate when the value of 'i' becomes 6 and will display incomplete output....

I have corrected the Program and it is below.....
#include
#include
void main()
{
int i,j=10;
clrscr();
for(i=1;i<=10;i++,j--)
{
printf("%d, %d ", i,j);
}
getch();
}

Unknown said...

I will I<=5;I<=10 is incorrect

Post a Comment