Skip to content

Commit 031ad53

Browse files
authored
Create 9.c
1 parent 549a1fe commit 031ad53

File tree

1 file changed

+37
-0
lines changed
  • Special Programs

1 file changed

+37
-0
lines changed

Special Programs/9.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include<stdio.h>
2+
int length(char *s)
3+
{
4+
int i=0;
5+
while(*(s+i)!='\0')
6+
{
7+
i++;
8+
}
9+
return i;
10+
}
11+
void reverse(char *s,int len)
12+
{
13+
int i,j=0;
14+
char x;
15+
for(i=len-1;i>=0;i--)
16+
{
17+
if(i>=j)
18+
{
19+
x=*(s+j);
20+
*(s+j)=*(s+i);
21+
*(s+i)=x;
22+
}
23+
j++;
24+
}
25+
*(s+len)='\0';
26+
}
27+
void main()
28+
{
29+
char s[100];
30+
int len;
31+
puts("Enter the string ");
32+
gets(s);
33+
len=length(s);
34+
reverse(s,len);
35+
puts("Reversed string :");
36+
puts(s);
37+
}

0 commit comments

Comments
 (0)