0% found this document useful (0 votes)
19 views

Reverse Word

This code takes a string as input from the user, reverses the order of characters in each word separated by spaces, and outputs the result. It uses loops and temporary variables to iterate through the string, identify word boundaries, and swap characters to reverse substrings between spaces.

Uploaded by

Shahrukh Alam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Reverse Word

This code takes a string as input from the user, reverses the order of characters in each word separated by spaces, and outputs the result. It uses loops and temporary variables to iterate through the string, identify word boundaries, and swap characters to reverse substrings between spaces.

Uploaded by

Shahrukh Alam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include<stdio.

h>
#include<string.h>
void main(){
int len=0,i=0,j=0;
char str[100],tmp[1];
printf("Enter a line of String= ");
gets(str);
while(str[i]!='\0'){
len=j=i;
while(str[len]!='\0'&& str[len]!=' ')len++;
i=len+1;len--;
while(len>j){
tmp[0]=str[j];
str[j++]=str[len];
str[len--]=tmp[0];
}
}
printf("The Reverse String =\n");

puts(str);
}

for(i=strlen(str)-1,j=0;j<i;j++,i--) {
temp=str[i];str[i]=str[j];str[j]=temp;}

for(i=strlen(str),j=0;j<=i;i++,j--) a[i]=a[j];

#include<stdio.h>
#include<conio.h>
void main( ){
Char n[100],char n1[20];char s;
int i=0;
gets(n);
For(i=strlen(n);i>=0;i--){ s=n.charAt(i);

if(s!='!' || s!=" " || s!='.')


{n1+=s;}
else{
n2=strev(n1);
Puts(n2);
n1=' ';}
getch();
}

You might also like