Write a C Program to Reverse Letter in Each Word of the Entered String
In this program we are going to accept a string . This program will check for word inside string and if word founds then program will reverse that word. Similarly it will reverse out all all the words.
#include<stdio.h> #include<conio.h> #include<string.h> void main() { char str[]="Welcome to Programming World"; char str1[10]; int i=0,j=0; clrscr(); while(str[i]!='\0') { if(str[i]!=' ') { str1[j]=str[i]; j++; } else { str1[j]='\0'; printf("%s", strrev(str1)); printf(" "); j=0; } i++; } str1[j]='\0'; printf("%s", strrev(str1)); getch(); }
Output :
emocleW ot gnimmargorP dlroW
Explanation of C Program :
Step 1 : Space Character Encountered
if(str[i]!=' ') { str1[j]=str[i]; j++; }
Store Character into Another String Variable. As soon as Space character encounters then reverse the string and print the String.
Incoming search terms:
- write a c program to reverse the words in a sentence in place (14)
- c program to reverse each word in a string (9)
- c program to reverse the words in a sentence in place (4)
- reverse each word in a string in c (4)
- wap to find reverse of a string in c without library function (1)
- write a c program to reverse the words in a sentence in place without using string function (1)