Facebook
Banner
XMPP JavaScript Library READ MORE

Program to reverse 'n' characters

Program to reverse 'n' characters

1 /*Reverse 'n' characters*/
2 #include <stdio.h>
3 #include <conio.h>
4 void reverse(char c[20],int i)
5 {
6 if(i>=0)
7 {
8 printf("%c",c[i]);
9 reverse(c,i-1);
10 }
11 }
12
13 void main()
14 {
15 char c[50];
16 int i,ctr=0;
17
18 printf("Enter your name:");
19 scanf("%s",&c);
20
21 for(i=0;i<50;i++)
22 {
23 ctr++;
24 if(c[i]=='\0')
25 break;
26 }
27 reverse(c,ctr-1);
28 getch();
29 }
Add Your Comment
   
    Yes! I want to receive all comments by email

No Comments Posted Yet. Be the first one to post comment