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


Please Help Members By Posting Answers For Below Questions

How can I dynamically allocate arrays?

606


What are the salient features of c languages?

634


Is c++ based on c?

663


What is the difference between #include and #include 'file' ?

618


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

1922






Describe explain how arrays can be passed to a user defined function

613


all c language question

1885


What are the __date__ and __time__ preprocessor commands?

586


Explain the Difference between the New and Malloc keyword.

694


Write a code to generate a series where the next element is the sum of last k terms.

745


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?

2066


What is external variable in c?

622


Write a program to print fibonacci series using recursion?

597


What is wrong in this statement? scanf(ā€œ%dā€,whatnumber);

738


Why is c still so popular?

628