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 is modifier & how many types of modifiers available in c?
What does sizeof function do?
What is the difference between array and structure in c?
main() { printf(5+"good morning"); printf("%c","abcdefgh"[4]); }the o/p is morning and e...how someone explain
which one is not preprocessor directive a)#if b)#elif c)#undef d)#pragma
16 Answers Accenture, Infosys, TCS, Wipro,
Dear Sir, we are required the bubble sorting programs Regs Prem
What are examples of structures?
Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?
What do you mean by team??
Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?
What does emoji p mean?
HOW TO ANSWER IF ASKED " WHAT KIND OF A PERSON ARE YOU?" I NEED AN ANSWER THAT IMPRESS THE INTERVIEWER