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 is clrscr in c?

0 Answers  


Print the foll in C...eg when n=5 the o/p must b + + + + + + + + + + + + + + + + +

1 Answers  


can u suggest me am in a confusion to choose whether to go to c programming or a software testing . am a graduate in B.sc(electronics).

1 Answers  


how to sort two array of characters and make a new array of characters.

1 Answers   Accenture,


What does stand for?

0 Answers  






Which is better between malloc and calloc?

0 Answers  


Write a function that will take in a phone number and output all possible alphabetical combinations

0 Answers   Motorola,


how to execute a program using if else condition and the output should enter number and the number is odd only...

0 Answers  


What is %s and %d in c?

0 Answers  


How we can insert comments in a c program?

0 Answers  


WAP that prints the number from 1 to 100. but for multiplies of three print "XXX" instead of the number and for the multiplies of five print "YYY" . for number which are multiplies of both three and five print "ZZZ"

3 Answers  


What is the difference between null pointer and wild pointer?

0 Answers  


Categories