Tutorials, Free Online Tutorials,It Challengers provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, core java, sql, php, c language etc. for beginners and professionals.

Breaking

Write a c program to short array element.

Program to short array element

#include<stdio.h>
#include<conio.h>

void main()
{
int i,a[10],temp,j;
clrscr();
printf("Enter any 10 num in array = \n");
for(i=0;i<=10;i++)
{
scanf("%d",&a[i]);
}
printf("\n\nData before sorting  = ");
for(j=0;j<10;j++)
{
printf("  %d",a[j]);
}
for(i=0;i<=10;i++)
{
for(j=0;j<=10-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("\n\n\nData after sorting   = ");
for(j=0;j<10;j++)
{
printf("  %d", a[j]);
}
getch();
}
Output:-



No comments:

Post a Comment