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
Explain built-in function?
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd
Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?
List some basic data types in c?
Write a C Program That Will Count The Number Of Even And Odd Integers In A Set using while loop
Apart from dennis ritchie who the other person who contributed in design of c language.
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
Write a program to know whether the input number is an armstrong number.
How is = symbol different from == symbol in c programming?
Explain Basic concepts of C language?
Why is c faster?
What is the difference between memcpy and memmove?
How can I call fortran?
Explain the properties of union.
Why we use int main and void main?