#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,j,n,temp;
clrscr();
printf("Enter the number of elements ");
scanf("%d",&n);
printf("Enter the number one by one ");
for (i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
for(i=0;i<n;i++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("Descending order:
");
for(i=0;i<n;i++)
printf("%d
",a[i]);
getch();
}
#include<conio.h>
void main()
{
int a[10],i,j,n,temp;
clrscr();
printf("Enter the number of elements ");
scanf("%d",&n);
printf("Enter the number one by one ");
for (i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
for(i=0;i<n;i++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("Descending order:
");
for(i=0;i<n;i++)
printf("%d
",a[i]);
getch();
}
0 comments:
Post a Comment