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
How can I dynamically allocate arrays?
What are the salient features of c languages?
Is c++ based on c?
What is the difference between #include and #include 'file' ?
the real constant in c can be expressed in which of the following forms a) fractional form only b) exponential form only c) ascii form only d) both a and b
Describe explain how arrays can be passed to a user defined function
all c language question
What are the __date__ and __time__ preprocessor commands?
Explain the Difference between the New and Malloc keyword.
Write a code to generate a series where the next element is the sum of last k terms.
Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?
What is external variable in c?
Write a program to print fibonacci series using recursion?
What is wrong in this statement? scanf(ā%dā,whatnumber);
Why is c still so popular?