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
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 |
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 |
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 |
What are the key features in c programming language?
Discuss similarities and differences of Multiprogramming OS and multiprocessing OS?
Write a program to print "hello world" without using a semicolon?
process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,
What is string in c language?
prototype of sine function.
Write a program to generate prime factors of a given integer?
int j =15,i; for (i=1; 1<5; ++i) {printf ("%d%d ",j,i); j = j-3; }
The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration
how can i sort numbers from ascending order and descending order using turbo c..
how to get the starting address of file stored in harddisk through 'C'program.
Write a program to print distinct words in an input along with their count in input in decreasing order of their count