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
Can we change the value of constant variable in c?
Disadvantages of C language.
Explain what is a const pointer?
WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER
any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()
Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent
Why doesnt this code work?
What are qualifiers and modifiers c?
Explain how can type-insensitive macros be created?
What is a scope resolution operator in c?
What are the 4 types of programming language?
What are the features of c language?
What is c system32 taskhostw exe?
Explain how can I open a file so that other programs can update it at the same time?
What is an arrays?