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 Posted / anshu ranjan
#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 ? | 10 Yes | 0 No |
Post New Answer View All Answers
Explain how can you restore a redirected standard stream?
In C, What is the #line used for?
What is the c value paradox and how is it explained?
What should malloc(0) do?
What does the file stdio.h contain?
What is context in c?
what is a function method?give example?
Why do we use stdio h and conio h?
What are the different types of endless loops?
What is variable declaration and definition in c?
What type of function is main ()?
Can you write the algorithm for Queue?
What does. int *x[](); means ?
How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same
Describe the order of precedence with regards to operators in C.