//========================
//Program in Cpp to learn to reverse a strings in Cpp, strrev.cpp
//========================
#include<iostream>
using namespace std;
int main()
{
char str[]="ProgramtoReverseString";
int length= strlen(str);
cout<<"***********Reversing a String******************";
cout<<"\n The given String is: \n \t";
for(int i=0;i<length;i++)
{
cout<<str[i];
}
//Reversing the String
int length2=length/2;
length--;
for(int i=0;i<length2;i++)
{
str[i]=str[i]+str[length-i];
str[length-i]=str[i]-str[length-i];
str[i]=str[i]-str[length-i];
}
cout<<"\n The Reversed String is:\n \t "<<str;
cout<<"\n";
return 0;
}
//Program in Cpp to learn to reverse a strings in Cpp, strrev.cpp
//========================
#include<iostream>
using namespace std;
int main()
{
char str[]="ProgramtoReverseString";
int length= strlen(str);
cout<<"***********Reversing a String******************";
cout<<"\n The given String is: \n \t";
for(int i=0;i<length;i++)
{
cout<<str[i];
}
//Reversing the String
int length2=length/2;
length--;
for(int i=0;i<length2;i++)
{
str[i]=str[i]+str[length-i];
str[length-i]=str[i]-str[length-i];
str[i]=str[i]-str[length-i];
}
cout<<"\n The Reversed String is:\n \t "<<str;
cout<<"\n";
return 0;
}
Program in C++/CPP/C to learn to reverse a strings in Cpp
ReplyDeleteProgram in C++/CPP/C to learn to reverse a strings in Cpp
Program in C++/CPP/C to learn to reverse a strings in Cpp
Program in C++/CPP/C to learn to reverse a strings in Cpp
Program in C++/CPP/C to learn to reverse a strings in Cpp
Program in C++/CPP/C to learn to reverse a strings in Cpp
Program in C++/CPP/C to learn to reverse a strings in Cpp
Program in C++/CPP/C to learn to reverse a strings in Cpp