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...

how can i sort numbers from ascending order and descending
order using turbo c..

Answer Posted / neha

If you are using the String class to store your names then you can use the < or > operators to compare the order, alphabetically, they appear in.

String names[3];
int numberOfNames = 3;
names[0] = "abc";
names[1] = "dfg";
names[2] = "hij";

printf("before %s%s%s\n", names[0],names[1],names[2]);
for( int i = 0; i < numberOfNames-1; i++ )
{
for( int j = 0; j < numberOfNames; j++ )
{
if( names[j] < names[j+1] )
{
names[j].swap( names[j+1] );
}
}
}

printf("after%s%s%s\n", names[0],names[1],names[2]);


output:
before abcdfghij
after hijdfgabc

Is This Answer Correct ?    4 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)

2118


write a program to rearrange the array such way that all even elements should come first and next come odd

2275


Under what circumstances does a name clash occur?

1199


Can you please explain the difference between syntax vs logical error?

1181


What does struct node * mean?

1011


What is variables in c?

1050


Why n++ execute faster than n+1 ?

2986


why return type of main is not necessary in linux

2104


What is header file definition?

1080


How many levels of indirection in pointers can you have in a single declaration?

1085


What would happen to X in this expression: X += 15; (assuming the value of X is 5)

1948


WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER

1856


What is the difference between functions abs() and fabs()?

1149


What are the types of arrays in c?

1174


Why does not c have an exponentiation operator?

1047