Skip to content

Commit 71b3423

Browse files
committed
String Sentance Reverse
1 parent 062b81a commit 71b3423

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

StringReverse.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* StringReverse.cpp
3+
*
4+
* Created on: 22-Jun-2017
5+
* Author: baliyan
6+
*/
7+
#include <iostream>
8+
#include <stdio.h>
9+
#include <string.h>
10+
static char str[]="Manoj is Searching";
11+
int reverse(int pos)
12+
{
13+
if(pos<(strlen(str)/2)){
14+
char ch;
15+
ch =str[pos];
16+
str[pos]=str[strlen(str)-pos-1];
17+
str[strlen(str)-pos-1]=ch;
18+
reverse(pos+1);
19+
}
20+
}
21+
int main()
22+
{
23+
printf("original String is [%s]\n",str);
24+
reverse(0);
25+
printf("String after reverse is [%s]\n",str);
26+
27+
28+
}
29+
30+
31+

0 commit comments

Comments
 (0)