1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Naddik [55]
3 years ago
12

Write a function to reverse a given string. The parameter to the function is a string. Function should store the reverse of the

given string in the same string array that was passed as parameter. Note you cannot use any other array or string. You are allowed to use a temporary character variable. Define the header of the function properly. The calling function (in main()) expects the argument to the reverse function will contain the reverse of the string after the reverse function is executed.
Computers and Technology
1 answer:
babymother [125]3 years ago
6 0

Answer:

Following are the program to this question:

#include <iostream> //defining header file

using namespace std;

void reverse (string a) //defining method reverse  

{

for (int i=a.length()-1; i>=0; i--)  //defining loop that reverse string value  

 {

     cout << a[i];  //print reverse value

 }

}

int main() //defining main method                                                                                          

{

string name; // defining string variable

cout << "Enter any value: "; //print message

getline(cin, name); //input value by using getline method

reverse(name); //calling reverse method

return 0;

}

Output:

Enter any value: ABCD

DCBA

Explanation:

In the above program code, a reverse method is declared, that accepts a string variable "a" in its arguments, inside the method a for loop is declared, that uses an integer variable "i", in which it counts string value length by using length method and reverse string value, and prints its value.

  • In the main method, a string variable "name" is declared, which uses the getline method.
  • This method is the inbuilt method, which is used to input value from the user, and in this, we pass the input value in the reverse method and call it.  
You might be interested in
Who like the videos where is clown is from :)
aev [14]

Answer:

i hate clowns alot especially pennywise lol

Explanation:

5 0
3 years ago
The tools, skills, knowledge, and machines created and used by humans is known as.
miskamm [114]

Answer:

Human capital

Explanation:

It means the economic value of workers experience and skills

7 0
2 years ago
A public Wi-Fi risk that can be minimized by only visiting
lord [1]

Answer

it is B

Explanation:

because i had the test and i picked that

6 0
3 years ago
Indicate whether the following statements are true or false:
postnew [5]

Answer:C

Explanation:I got it correct on the computer

7 0
3 years ago
Read 2 more answers
A common use of color in a document is in Table Headers. Which of these is NOT a common way to use color in a table header.
Lesechka [4]
<span>Use a dark color with light-color text to contrast the headers with the data.</span>
3 0
3 years ago
Other questions:
  • Search the internet for news of a motor vehicle collision in your community involving drugs or alcohol. Keeping in mind that you
    15·1 answer
  • Consider what fact-finding techniques you would use to identify the important facts needed to develop a database system. Please
    7·1 answer
  • Given a int variable named yesCount and another int variable named noCount and an int variable named response write the necessar
    6·1 answer
  • What do developers do to support software products
    14·1 answer
  • PLEASE HELP ME ANSWER AS MUCH AS YOU CAN I ONLY HAVE 3 POINTS LEFT AND IM TIMED. PLEASE TELL ME THE NUMBER AND LETTER. THANK YOU
    5·1 answer
  • Explain the saying "Dress for the position you want, not the position you have."
    6·2 answers
  • What is the unit used to describe the intensity of sound?
    5·1 answer
  • What happens when a string doesn’t include the separator that’s specified in the parameter of the split() method?
    13·1 answer
  • You can use tables for layout work. However, in XHTML, each form control should have its own ______ element
    12·1 answer
  • Which of the following is the most significant result of technological innovation?
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!