/*
Program to reverse a string like - "program to reverse the string in c" to convert this string into "c in string the reverse to program"
Created By: Pirate
*/
#include<string.h>
void main(){
int i,j,k;
char s[100];
printf("Enter a string\n");
gets(s);
k=strlen(s);
for(i=k;i>=0;i--){
if(s[i]==' '){
for(j=i+1;j<k;j++){
printf("%c",s[j]);
}
printf(" ");
k=i;
}
}
for(i=0;i<k;i++)
printf("%c",s[i]);
}
Output
Program to reverse a string like - "program to reverse the string in c" to convert this string into "c in string the reverse to program"
Created By: Pirate
*/
#include<string.h>
void main(){
int i,j,k;
char s[100];
printf("Enter a string\n");
gets(s);
k=strlen(s);
for(i=k;i>=0;i--){
if(s[i]==' '){
for(j=i+1;j<k;j++){
printf("%c",s[j]);
}
printf(" ");
k=i;
}
}
for(i=0;i<k;i++)
printf("%c",s[i]);
}
Output
0 comments:
Post a Comment