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 does 3 periods mean in texting?

1067


To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9

2642


How to write a program for machine which is connected with server for that server automatically wants to catch the time for user of that machine?

2101


What does the && operator do in a program code?

1240


Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?

1506


What is the use of a ‘’ character?

1094


how can use subset in c program and give more example

1997


When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd

1062


What is the use of pointers in C?

1084


What's the best way of making my program efficient?

1110


Can the curly brackets { } be used to enclose a single line of code?

1173


How to write c functions that modify head pointer of a linked list?

992


a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above

1233


Differentiate between calloc and malloc.

1275


What is action and transformation in spark?

1166