C program to print the given numbers in Ascending Order
C program to print numbers in Ascending Order
In this post, i will share a C program to to print the given numbers in ascending order using simple for loop.
#include <stdio.h>
#include <conio.h>
void main()
{
int i,j,x,n,num[10];
clrscr();
printf("enter N: ");
scanf("\n%d",&n);
printf("\nEnter number:\n");
for(i=0;i<n;i++)
{
scanf("%d",&num[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(num[i]>num[j])
{
x=num[i];
num[i]=num[j];
num[j]=x;
}
}
}
printf("\nNumber arranged in ascenging order:\n");
for(i=0;i
Comments
Post a Comment