C program to Reverse a string - My CS Tutorial - My CS Tutorial

Breaking

Programming languages full tutorial and programs, exam papers, visual basic( Vb.net ), information of new technologies and more....

Monday, January 20, 2020

C program to Reverse a string - My CS Tutorial

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.

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