ALLInterview.com :: Home Page KalAajKal.com
 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                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
write an algorithm to get a sentence and reverse it in the
following format:
input : I am here
opuput: Here Am I
note: first letter of every word is capiatlised
 Question Submitted By :: DayQuest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: write an algorithm to get a sentence and reverse it in the following format: input : I am here opuput: Here Am I note: first letter of every word is capiatlised
Answer
# 1
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

void main()
{char *s,*t;
 int i=0,j=0;
 s=(char *)malloc (1000*sizeof(char));
 t=(char *)malloc (50*sizeof(char));
 gets(s);
 i=strlen(s)-1;
 while(i>=-1)
	{
	 if(s[i]!=' ' && i>=0)
		t[j++]=s[i--];
	 else {if(t[j-1]>=97 && t[j-1]<=122)
				t[j-1]-=32;
			 i--;
			 t[j]=0;
			 //printf("%s ",t);
			 strrev(t);
			 printf("%s ",t);
			 j=0;
			}
	}
}
 
Is This Answer Correct ?    5 Yes 0 No
Anshu Ranjan
 
  Re: write an algorithm to get a sentence and reverse it in the following format: input : I am here opuput: Here Am I note: first letter of every word is capiatlised
Answer
# 2
here using pointers we can easily do the above..........


#include<stdio.h>
#include<conio.h>
#include<alloc.h>
void main()
{
char a[50],*ptr,*pointer;
int n,i,j,k;
printf("enter the string:");
gets(a);
for(i=0;a[i]!='\0';i++)
n++;
pointer=(char*)malloc((n+1)sizeof('2'));
j=0;
for(i=0;a[i]!='\0';)
{
 if(a[i]==' ')
 {
  *(pointer+(n-j-1))=a[i];
i++; j++;
 }
else
{
ptr=&a[i];
 for(k=0;a[i+1]!=' '&&a[i+1]!='\0';k++)
  i++;
 for(k=0;k<((&a[i]-ptr)+1);k++)
 {
  *(pointer+(n-j-1))=*(ptr+(&a[i]-ptr)-k);
j++;
 }
}
i++;
}
  *(pointer+(n+1))='\0';
for(i=0;i<n;i++)
printf("%c",*(pointer+i));
getch();
}



thank u
 
Is This Answer Correct ?    1 Yes 1 No
Vignesh1988i
 
 
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
WHAT IS MAXIMUM SIZE OF AN ARRAY IN C LANGUAGE? IBM5
what is the difference b/w compiler and debugger? Assurgent1
An interactive c program to read basic salary of 15 persons. each person gets 25% of basic as HRA, 15%of basic as conveyance allowances, 10%of basic as entertainment allowances.The total salary is calculated by adding basic+HRA+CA+EA.Calculate how many out of 15 get salary above 10,000.Rs also print the salary of each employee  2
how can i get this by using for loop? * ** * **** * ****** Excel3
differentiate between const char *a; char *const a; and char const *a; HCL1
sqrt(x+sqrt(x+sqrt(x+sqrt(x))))=2; Find the value of x? Subex2
There is a 100-story building and you are given two eggs. The eggs (and the building) have an interesting property that if you throw the egg from a floor number less than X, it will not break. And it will always brake if the floor number is equal or greater than X. Assuming that you can reuse the eggs which didn't broke; you got to find X in a minimal number of throws. Give an algorithm to find X in minimal number of throws.  2
write a program to sort the elements in a given array in c language  2
What is the meaning When we write "#include" what is # and what does include does there??? HCL11
tell me the full form of c?  2
wap in c to accept a number display the total count of digit  4
Which of the following is not a valid declaration for main ()? 1) int main() 2) int main(int argc, char *argv[]) 3) They both work  2
how to find out the biggest element (or any other operation) in an array which is dynamic. User need not to mention the array size while executing.  2
print the following using nested for loop. 5 4 3 2 1 1 2 3 4 3 2 1 1 2 1 2 1 1 2 3 4 3 2 1 1 2 3 4 5  5
what is const volatile?  1
Find Error if any in below code, Justify ur answer: struct xx { int a; struct yy { char c; struct xx* p; } struct yy* q; } NDS3
what are the compilation steps? ( i want inside the compiler )  1
Can we write a program without main() function?  9
a.One Cannot Take the address of a Bit Field b.bit fields cannot be arrayed c.Bit-Fields are machine Dependant d.Bit-fields cannot be declared as static Which of the Following Statements are true w.r.t Bit-Fields A)a,b&c B)Only a & b C)Only c D)All Accenture2
related to rdbms query .  1
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com