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 / hguyiyo

#include<stdio.h>
main()
{
int i, count=0;
int n,num,t;
scanf("%d",&n);
int a[n];
while(count!=n)
{
scanf("%d",&num);
a[count]=num;
++count;

}
for(i=0;i<n;++i) printf(" %d ",a[i]);
printf("\n\n\n\n");
for(i=0;i<n;++i)
if(a[i]<=a[i+1]) ;
else
{
t=a[i];
a[i]=a[i+1];
a[i+1]=t;
}
for(i=0;i<n;++i) printf(" %d ",a[i]);
}

Is This Answer Correct ?    4 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are pointers? What are different types of pointers?

1132


What are directives in c?

970


How is null defined in c?

1150


What is the maximum no. of arguments that can be given in a command line in C.?

1142


What is return in c programming?

967


Tell us bitwise shift operators?

1091


What are the characteristics of arrays in c?

1049


Explain zero based addressing.

1019


what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?

1855


the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?

993


What are the different types of control structures?

1040


Why is it that not all header files are declared in every C program?

1212


What is a struct c#?

1047


Want to know how to write a C program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

2050


What is dynamic dispatch in c++?

1051