#include <stdio.h>
int arrange(int[],int);
main()
{
int array[10],num,i,flag;
clrscr();
puts("Enter length of array");
scanf("%d",&num);
puts("Enter the enties:");
for( i=0; i<=num-1; i++)
{
printf("\n(%d).......",i+1);
scanf("%d",&array[i]);
}
do
{
flag=arrange(array,num);
}while( flag==-1);
printf("\nThe array in desending order is: ");
for(i=0; i<=num-1; i++)
printf("\n\t\t***** %3d *****",array[i]);
getch();
}
int arrange(int *block,int num)
{
int j,status,temp;
status=1;
for( j=0;j<num-1;j++)
{
if(block[j] < block[j+1])
{
temp=block[j];
block[j]=block[j+1];
block[j+1]=temp;
status=-1;
}
}
return(status);
}
Can someone help me simulate this program?? i know how this program works but i don't understand what is the use of the flag in the program!