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
Write a cout statement that prints the value of a conditional expression. The conditional expression should determine whether th
zheka24 [161]

Answer:

#include <iostream>

using namespace std:

int main (){

int score=0;

cin>>score;

if (score==100)

cout << "Perfect";

else

cout <<"Nice Try";

return 0;

}

Explanation:

7 0
3 years ago
For which input values will the following loop not correctly compute the maximum of the values? 1. Scanner in = new Scanner (Sys
My name is Ann [436]

Answer:

The answer is "Option d".

Explanation:

Please find the complete question in the attached file.

8 0
3 years ago
If you want to create a line of code that will not appear in the interpreter, what symbol should begin the line?
kirill115 [55]

Answer:

endl

Explanation:

Note that endl must be free of quotation marks; otherwise, the program will treat it as a string.. The \n Character. The other way to break a line in C++ is to use the newline character

5 0
2 years ago
President Roosevelt's Fireside Chats were:
larisa86 [58]
C. Entertaining radio shows that families listened to in the evening. He did these chats to inform the public on what he was going to do about the problems facing the public.
3 0
3 years ago
Read 2 more answers
Write the pseudocode for a program that will process attendance records of CA students. The students attend college five days a
Alenkasestr [34]

Using the knowledge of pseudocodes it will be possible to write a code that calculates the amount of hours worked and giving warnings about it.

<h3>Writing a pseudocode we have that:</h3>

<em>while </em>

<em>if number == 0</em>

<em>break</em>

<em>hours =0 </em>

<em>for i =1 to 5 </em>

<em>hours = hours + time_out[ i ] - time_in[ i ]</em>

<em> If hours >36 : </em>

<em>print ( "Name is " ,name)</em>

<em>print( "No of hours are ",hours)</em>

<em>print("Congratulaion! Your working hours are more than 36")</em>

<em>If hours <30 : #</em>

<em>print ( "Name is " ,name)</em>

<em>print( "No of hours are ",hours)</em>

<em>print("Warning !!!")</em>

<em>End loop</em>

See more about pseudocode at brainly.com/question/13208346

#SPJ1

3 0
2 years ago
Other questions:
  • Jeffrey works with a huge database of spreadsheet records each day. To organize and identify these spreadsheets, he wants to ass
    8·1 answer
  • Which company operates a public cloud?<br><br> Lotus<br> Acme<br> Google<br> Symantec
    5·2 answers
  • _____ provides vital protection and maintenance services for system hardware and software, including enterprise computing system
    12·1 answer
  • What is the film format that many filmmakers feel is superior to any other format?
    13·1 answer
  • On his computer desktop, Rodney can see several different files, each immediately accessible. Because he is actively working on
    13·1 answer
  • Write a program that asks the user to enter a student's name and 8 numeric tests scores (out of 100 for each test). The name wil
    13·1 answer
  • Stock Market
    11·1 answer
  • What is the best way of farming exotics in destiny?
    12·2 answers
  • Which of the following is NOT an example of soft skill?
    10·2 answers
  • Can someone take away your points
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!