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 / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
char a[50],temp;
int count=0;
printf("enter the string");
gets(a);
for(int i=0;a[i]!='\0';i++)
count++;
for(i=0;i<count;i++)
{
for(int j=0;j<count;j++)
{
if(a[j]=a[j+1];
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("\n");
puts(a);
getch();
}

thank u

Is This Answer Correct ?    1 Yes 27 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the advantages of c preprocessor?

715


What are the advantages of union?

630


Which is best linux os?

567


Is it fine to write void main () or main () in c?

549


What is variable initialization and why is it important?

623






Write a program of advanced Fibonacci series.

711


which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above

1138


Do you know what are bitwise shift operators in c programming?

589


What is realloc in c?

581


What does d mean?

587


What is a function in c?

577


What is the function of this pointer?

678


Explain what are reserved words?

635


How do you determine the length of a string value that was stored in a variable?

652


What is malloc return c?

603