Skip to content

Commit 272ccfb

Browse files
Merge pull request #181 from PranjalBagal/patch-1
Create StringReverse.c
2 parents 7641745 + 86fc2b6 commit 272ccfb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

StringReverse.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include<stdio.h>
2+
#include<conio.h>
3+
void main()
4+
{
5+
int i, j, k;
6+
char str[100];
7+
char rev[100];
8+
printf("Enter a string:\t");
9+
scanf("%s", str);
10+
printf("The original string is %s\n", str);
11+
for(i = 0; str[i] != '\0'; i++);
12+
{
13+
k = i-1;
14+
}
15+
for(j = 0; j <= i-1; j++)
16+
{
17+
rev[j] = str[k];
18+
k--;
19+
}
20+
printf("The reverse string is %s\n", rev);
21+
getch();
22+
}

0 commit comments

Comments
 (0)