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

Answers were Sorted based on User's Feedback



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

Answer / chumurva

its working but not correct.

Is This Answer Correct ?    6 Yes 0 No

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

Answer / naveen

Then which one is the answer. i think the above one works
perfectly and they both will yield you the same results
which you wanted.

is this a tricky qustion? if so whats the answer for this

Is This Answer Correct ?    2 Yes 3 No

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

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

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

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

More C Interview Questions

What are the features of c languages?

0 Answers  


What are pointers? Why are they used?

0 Answers  


Where is volatile variable stored?

0 Answers  


any "C" function by default returns an a) int value b) float value c) char value d) a & b

0 Answers  


What is boolean in c?

0 Answers  






Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer

0 Answers   Ignou, Microsoft,


two variables are added answer is stored on not for third variable how it is possible?

3 Answers  


Write code for atoi(x) where x is hexadecimal string.

5 Answers   Adobe,


write a 'c' program to sum the number of integer values

8 Answers  


What is #include stdlib h?

0 Answers  


What are pointers? What are stacks and queues?

0 Answers   Hexaware,


main() { printf("hello"); fork(); }

0 Answers   Wilco,


Categories