C Program to Sort the Array in an Ascending Order.
CODING:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[50],i,n,k,temp=0;
clrscr();
printf("How many enter the element:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter Number:");
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(k=0;k<n;k++)
{
if(a[i]<=a[k])
{
temp=a[i];
a[i]=a[k];
a[k]=temp;
}
}
}
printf("Your list.");
for(i=0;i<n;i++)
{
printf("\n-> %d",a[i]);
}
getch();
}
CODING:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[50],i,n,k,temp=0;
clrscr();
printf("How many enter the element:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter Number:");
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(k=0;k<n;k++)
{
if(a[i]<=a[k])
{
temp=a[i];
a[i]=a[k];
a[k]=temp;
}
}
}
printf("Your list.");
for(i=0;i<n;i++)
{
printf("\n-> %d",a[i]);
}
getch();
}
Comments
Post a Comment