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 / m. ahsan

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

//Sorting an array with a single FOR loop. No complex coding and testing with multiple array sizes.

int main()
{ clrscr();

int xlist[5]={5,3,4,1,2};

int i,temp;

for (i=0;i<4;)
{
if (xlist[i]<xlist[i+1])
i++;
else
{ temp=xlist[i];
xlist[i]=xlist[i+1];
xlist[i+1]=temp;
i=0;
}
}

for (i=0;i<5;i++)
{ printf("%d ",xlist[i]); }

getch();
return 0;
}

Is This Answer Correct ?    14 Yes 15 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Differentiate between the expression “++a” and “a++”?

1206


On most computers additional memory that is accessed through an adapter of feature card along with a device driver program. a) user memory b) conventional memory c) expandedmemory d) area

1073


What are the types of functions in c?

939


write a program in c language to print your bio-data on the screen by using functions.

6735


What is pointer & why it is used?

1063


What is define c?

1003


A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream

1120


Between macros and functions,which is better to use and why?

2118


write a programming in c to find the sum of all elements in an array through function.

2117


What is data structure in c language?

1061


What are structure types in C?

1050


Using functions, write a program that multiplies two arrays. Use the following functions: - Function ReadArray - Function MultiplyArrays - Function DisplayArrays

2302


What is getche() function?

989


Do string constants represent numerical values?

1326


Explain high-order and low-order bytes.

1052