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

if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0

0 Answers  


a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion

0 Answers   Mindteck,


What do header files do?

0 Answers  


What is the Lvalue and Rvalue?

2 Answers  


Why & is used in c?

0 Answers  






Is there a way to jump out of a function or functions?

0 Answers  


What is the difference between declaring a variable by constant keyword and #define ing that variable?

1 Answers  


What does void main () mean?

0 Answers  


what will be the out put. #include<stdio.h> void main() { printf("Output:"); printf(1+"vikashpatel"); }//output: ikashpatel

1 Answers   V2 Solutions,


Why #include is used in c language?

0 Answers  


Explain what standard functions are available to manipulate strings?

0 Answers  


Why array starts with index 0

2 Answers  


Categories