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

What is zero based addressing?

1167


How do you define CONSTANT in C?

1267


How to delete a node from linked list w/o using collectons?

2775


Why do we write return 0 in c?

1049


Explain void pointer?

1039


When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

1269


What are disadvantages of C language.

1158


Why is c platform dependent?

1084


write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays

2240


What are the 5 organizational structures?

1023


Why does not c have an exponentiation operator?

1047


How will you print TATA alone from TATA POWER using string copy and concate commands in C?

1365


List the different types of c tokens?

1072


What is pivot in c?

1024


What is the data segment that is followed by c?

1081