Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a program to sort the elements in a given array in c
language

Answer Posted / dibyendu

#include<stdio.h>
#include<conio.h>
void main()
{
int ar[100],j,n,i,tmp;
printf(" Enter the size of the array \t");
scanf("%d",&n);
printf("Now enter the elements in the array \n");
for(i=0;i<n;i++)
{
scanf("%d",&ar[i]);
}
printf("\n Array is - ");
for(i=0;i<n;i++)
{
printf("\t %d",ar[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
if(ar[j]>ar[j+1])
{
tmp=ar[j];
ar[j]=ar[j+1];
ar[j+1]=tmp;
}
}
}
printf("\n\n Array in the ascending order is - \n");
for(i=0;i<n;i++)
{
printf("\t %d",ar[i]);
}
getch();
}

Is This Answer Correct ?    7 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the 3 types of structures?

980


How do you override a defined macro?

1209


Is using exit() the same as using return?

1250


What is the hardest programming language?

1099


Why we use break in c?

935


List a few unconditional control statement in c.

929


What is the difference between far and near ?

1156


c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above

993


What is a 'null pointer assignment' error?

1162


Which is best linux os?

972


Do you know the difference between malloc() and calloc() function?

1005


What is main return c?

935


What is hashing in c language?

1188


Why is extern used in c?

1051


Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?

2500