#include<stdio.h>
#include<conio.h>
void main()
{
int arr[5],i,j,temp;
clrscr();
printf("Enter any five elements in an Array==>\n");
for(i=0;i<=4;i++)
{
scanf("%d",&arr[i]);
}
printf("\n\n Accepted Array Elements are==>");
for(i=0;i<=4;i++)
{
printf("\n arr[%d]=%d",i,arr[i]);
}
for(i=0;i<=4;i++)
{
for(j=0;j<=4;j++)
{
if(arr[i]<arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
printf("\n\n The number in ascending order are==>");
for(i=0;i<=4;i++)
{
printf("\n arr[%d]=%d",i,arr[i]);
}
getch();
}
/************************** OUTPUT WINDOW ************************/
Enter any five elements in an Array==>
9
1
8
2
3
Accepted Array Elements are==>
arr[0]=9
arr[1]=1
arr[2]=8
arr[3]=2
arr[4]=3
The number in ascending order are==>
arr[0]=1
arr[1]=2
arr[2]=3
arr[3]=8
arr[4]=9
No comments:
Post a Comment