Reverse the string using in C and C++ program

Bismillahir Rahmanir Rahim
 Solution: In C program:------

#include <stdio.h>
#include <string.h>
 
void main()
{
   char str[30];
 
   printf("Enter a string to reverse:\n");
   gets(str);
 
   strrev(str);
 
   printf("Reverse of entered string is:\n%s",str);

}
Solution:In C++ program:----

#include <iostream.h>
#include <string.h> 
void main()
{
   char str[30];
 
   cout<<"Enter a string to reverse:"<<endl;
   cin.getline(str,30);
 
   strrev(str);
 
   cout<<"Reverse of entered string is:"<<endl<<str;

}

Socializer Widget By Blogger Yard
SOCIALIZE IT →
FOLLOW US →
SHARE IT →