C program to reverse a string

C program to reverse a string

#include<stdio.h>
#include<conio.h>
#include<string.h>

void main()
{
int i,n;
char a[30];
clrscr();
printf(“Enter any string:”);
gets(a);

n=strlen(a);
printf(“Reverse of string:”);
for(i=(n-1);i>=0;–i)
printf(“%c”,a[i]);
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *