ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Software >> Programming Languages >> C
 
 


 

 
 C interview questions  C Interview Questions (2266)
 C++ interview questions  C++ Interview Questions (1121)
 VC++ interview questions  VC++ Interview Questions (342)
 Delphi interview questions  Delphi Interview Questions (510)
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions (652)
Question

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
 Question Submitted By :: C
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
its working but not correct. 
Is This Answer Correct ?    6 Yes 0 No
Chumurva
 
Answer
# 2
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
Naveen
 
 
 
Answer
# 3
#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 ?    5 Yes 20 No
Yogesh Bansal
 
Answer
# 4
#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 ?    0 Yes 23 No
Vignesh1988i
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
what do structure language means? Microsoft 3
What are the phases in s/w developed life cycle? wat is the diff b/w stack & queue...where do we use stack   6
though sbi was nationalized why its not comes under nationalized banks and its comes under publicsector banks State-Bank-Of-India-SBI 3
How do I access command-line arguments? Wipro 2
main() { int x=2, y=4 if ((x==2||y==4) x++ y++ if (y==4+1) { x=x+y; } y++; printf("The values of x and y are %d and %d."x,y); } What is the output? TCS 5
Tell about strtok & strstr functions Motorola 2
How do you write a program which produces its own source code as its output?   2
True or false: If you continuously increment a variable, it will become negative? 1) True 2) False 3) It depends on the variable type   7
write a program to delete an item from a particular location of an linear array?   1
main() { char x; while(x=0;x<=255;x++) printf("\nAscii value %d Charater %c",x,x); }   2
define switch statement? CTS 6
how to print this sereis 2 4 3 6 5..........?   2
 
For more C Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com