Code:
#include <stdio.h>
#include <conio.h>
#define ROW 5
main()
{
int unsorted[ROW] ;
int i ;
int j ;
printf("Enter %d numbers\n", ROW);
for(i=0;i<ROW; i++)
{
scanf("%d", &unsorted[i]) ;
}
for(i=0;i<ROW;i++)
{
if(unsorted[i] <= unsorted[i+1])
{
unsorted[i] = 999 ;
for(i=0;i<ROW;i++)
{
printf("%d\t", unsorted[i]) ;
}
}
}
printf("\n") ;
for(i=0;i<ROW;i++)
{
if(unsorted[i] <= unsorted[i+1])
{
unsorted[i] = 999 ;
for(i=0;i<ROW;i++)
{
printf("%d\t", unsorted[i]) ;
}
}
}
for(i=0;i<ROW;i++)
{
if(unsorted[i] <= unsorted[i+1])
{
unsorted[i] = 999 ;
for(i=0;i<ROW;i++)
{
printf("%d\t", unsorted[i]) ;
}
}
}
getch() ;
}
Ok i fixed the problem but i need about 3 loops!! why can't i use just one loop?