Write a function that accepts a sentence as a parameter, and
returns the same with each of its words reversed. The
returned sentence should have 1 blank space between each
pair of words.
Demonstrate the usage of this function from a main program.
Example:
Parameter: “jack and jill went up a hill” Return Value:
“kcaj dna llij tnew pu a llih”
Answer Posted / jeke kumar gochhayat
#include<stdio.h>
#include<string.h>
char *strrev1(char *st);
void main()
{
char st1[30];
char *pt1;
printf("enter the sentence");
gets(st1);
pt1=strrev1(st1);
puts(pt1);
}
char *strrev1(char *st)
{
int i;
char *pt=st;
for(i=0;st[i]!='\0';i++);
st[i]=' ';
st[i+1]='\0';
i=0;
for(;st[i]!='\0';i++)
{
for(;st[i]!=' ';i++);
st[i]='\0';
strrev(pt);
pt=st+i+1;
st[i]=' ';
}
return(st);
}
| Is This Answer Correct ? | 37 Yes | 5 No |
Post New Answer View All Answers
Why is c called c not d or e?
What is array of pointers to string?
What is a nested loop?
What is a sequential access file?
What is use of null pointer in c?
Explain what is the stack?
What is the use of typedef in structure in c?
What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.
typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none
code for find determinent of amatrix
what do u mean by Direct access files? then can u explain about Direct Access Files?
What is new line escape sequence?
How to declare pointer variables?
Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.
What are the uses of null pointers?