C program to get reverse of a given string.
In this tutorial we will discuss that how to write a simple C program to find the reverse of a string that string entered by user using keyboard.
In this tutorial we will discuss that how to write a simple C program to find the reverse of a string that string entered by user using keyboard.
C program code
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i,j=0;
char str1[100],str2[100]={0};
clrscr();
printf("\n ENTER A STRING TO FIND REVERSE STRING:\n ");
gets(str1);
for(i=strlen(str1)-1;i>=0;i--)
{
str2[j]=str1[i];
j++;
}
str2[j]='\0';
printf("\n THE REVERSE OF THAT STRING IS:\n %s\n",str2);
getch();
}
OUTPUT:
Please share this post and blog link with your friends.For more programs use this blog.
If you have any problem, please comment in comment box, subscribe this blog for notifications of new post on your email and follow this blog.If you have any method of this program or want to give any suggestion send email on hc78326@gmail.com
Created by-- HARSH CHAUHAN
No comments:
Post a Comment