62 548
Assignments Done
98,7%
Successfully Done
In June 2018

Answer to Question #20173 in C++ for apoorva

Question #20173
Write a program to reverse a string
(i)using another array
(ii)without another array
Expert's answer

#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>

void main()
{

int str[50], rev[50];

cout<< "
Enter a string :";
gets(str);
int l = strlen(str);

/* Reverse String using another array */
for( int i = l-1, k = 0 ; i>= 0 ; i--, k++)
rev[k] = str[i];

cout<< "
Original String is "<< str;
cout<< "
Reverse String is "<< rev ;
cout<< "
Reverse String is ";

/* Reverse String without using another array */
for( i = l-1 ; i>=0 ; i--)
cout<< str[i];

getch();

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions