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


I need to take a sentence from input and sort the words
alphabetically using the C programming language.

Note: This is C not C++.
qsort and strtok not allowed

Answer Posted / yogesh bansal

#include <stdio.h>

int main()
{
char arr[100];
int count =0;
int j,i,k;
char temp;
printf("enter the string\n");
gets(arr);
for(i=0;arr[i]!='\0';i++)
count++;
printf("value of count is %d\n",count);
for(k=0;k<=count;k++)
{
for(j=0;j<count-1;j++)
{
if(arr[j]>arr[j+1])
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}

}
}
puts(arr);
return 0;
}

This is the correct and working program.

Is This Answer Correct ?    6 Yes 23 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Are global variables static in c?

1212


What is the difference between far and near in c?

1121


What are the data types present in c?

1234


Is c object oriented?

1011


What are the types of pointers in c?

1078


‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.

2384


How do you use a pointer to a function?

1147


program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)

2144


Explain how does flowchart help in writing a program?

1167


What should malloc() do? Return a null pointer or a pointer to 0 bytes?

1135


Explain the use of fflush() function?

1130


Why isnt there a numbered, multi-level break statement to break out

1099


What is pointers in c with example?

1134


What is a volatile keyword in c?

1212


What is the difference between arrays and pointers?

1173