String reverse

Description:

Write a program to join and reverse a string. Test Case 1 Input (stdin) Programming Expected Output gnimmargorP Test Case 2 Input (stdin) HAPPY:) Expected Output ):YPPAH

Program :

#include<iostream>

#include<string.h>

using namespace std;

int main ()

{

    char str[50], temp;

    int i, j;

    //cout << "Enter a string : ";

    cin>>str;

    j = strlen(str) - 1;

    for (i = 0; i < j; i++,j--)

    {

        temp = str[i];

        str[i] = str[j];

        str[j] = temp;

    }

    cout << str;

    return 0;

}