adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Program in C++ to reverse a given string

Program in C++ to reverse a given string



#include<iostream>
#include<string.h>
#include<conio.h>
 using namespace std;
  void StrRev(char *str1)
  	 {
		int i,len,temp;
		len=strlen(str1);
		for(i=0;i<=len/2;i++)
		 {
		 	temp=str1[i];
		 	str1[i]=str1[len-1-i];
		 	str1[len-1-i]=temp;
		 }
	 } 
	 int main()
	 {
	 	char str1[100];
	 	cout<<"Enter string :-";
	 	cin.getline(str1,99);
	 	StrRev(str1);
	 	cout<<" Reverse  ="<<str1;
	 	return 0;
	 }
	
Output:-







Related Programs :- 
  1. Program in C++ to compare two string
  2. Program in C++ to copy one word into another word
  3. Program in C++ to add two string
  4. Program in C++ to convert string Uppercase to Lowercase
  5. Program in C++ to count words in given sentence
  6. Program in C++ to convert string  Lowercase to Uppercase 

Post a Comment

0 Comments