OUTPUT:
TIMER:
UNDERSTAND THIS CODE 60 seconds.
CONCEPT:
First, we have entered the size of the array then the loop will iterate that times(like i entered 4 so the loop will iterate 4 times to enter the array)
C CODE(RUNS ON TURBO C++):
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,a[5],n;
clrscr();
scanf("%d",&n); //here we are taking size.
for(i=0;i<n;i++)
{
scanf("%d",&a[i]); //entering numbers to sorting
}
for(i=0;i<n-1;i++) //loop is running upto n-1 because i is starting from 0
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
k=a[i];
a[i]=a[j];
a[j]=k;
}
}
}
for(i=0;i<n;i++)
{
printf("%d",a[i]);
}
getch();
}
0 Comments
if you have any doubt, plz let me know