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

Explain continue keyword in c

1063


a value that does not change during program execution a) variabe b) argument c) parameter d) none

1286


What is the general form of #line preprocessor?

1039


Write a progarm to find the length of string using switch case?

2120


Why we write conio h in c?

1077


What is call by reference in functions?

1533


What is modifier & how many types of modifiers available in c?

1071


Write a program to reverse a linked list in c.

1177


What is c basic?

1219


What is the difference between int main and void main in c?

1235


How can I read a binary data file properly?

1244


What is a class c rental property?

1144


How can I do peek and poke in c?

1135


Is main is user defined function?

1206


How do I round numbers?

1050