main()
{
int in[5], temp=0 ,i=0,j;
//----input
printf("Enter 5 digits \n\n");
for(i=0;i<5;i++)
{
scanf("%d",&in[i]);
}
//-----sort
for(i=0;i<5;i++)
{
for(j=i+1;j<5;j++)
{
if(in[i]>in[j])
{
temp=in[i];
in[i] = in[j];
in[j] = temp;
}
}
}
//-----output
/*printf("\nafter sorting \n\n");
for(i=0;i<5;i++)
{
printf("%d \n",in[i]);
} */
//Print the samllest
printf("the smallest number : %d \n",in[0]);
//Print the largest
printf("the largest number : %d \n",in[4]);
}
No comments:
Post a Comment