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
valina [46]
3 years ago
12

Write a c++ program that accepts a string from the user and then replaces all occurrences of the letter e with the letter x

Computers and Technology
1 answer:
mixer [17]3 years ago
6 0

Answer:

#include <iostream>

using namespace std;

int main()

{

   string str;

   cout<<"Enter the string: ";

   cin>>str;

   for(int i=0;str[i]!='\0';i++){

       if(str[i]=='e'){

           str[i]='x';

       }

   }

   cout<<"the string is: "<<str<<endl;

  return 0;

}

Explanation:

First, include the library iostream for using the input/output instructions.

Create the main function and declare the variables.

Then, use the cout instruction and print the message on the screen.

cin store the string enter by the user into a variable.

After that, take a for loop and if-else statement for checking the condition if the string contains the 'e', then change that alphabet to 'x'.

This process continues until the string not empty.

Finally, print the updated string.

You might be interested in
Although a tablet can connect to a cellular network, it cannot be used as a
Misha Larkins [42]

Answer:

A tablet can have mobile data such as MetroPCS. But the tablet can not make phone calls or texts.

7 0
3 years ago
Read 2 more answers
g Assignment 8: Driving costs Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon as input, a
zavuch27 [327]

Answer:

miles_gallon = float(input("Enter car's miles/gallon: "))

dollars_gallon = float(input("Enter gas dollars/gallon: "))

print("Gas cost for 20 miles is $", (20 / miles_gallon) * dollars_gallon)

print("Gas cost for 75 miles is $", (75 / miles_gallon) * dollars_gallon)

print("Gas cost for 500 miles is $", (500 / miles_gallon) * dollars_gallon)

Explanation:

*The code is in Python.

Ask the user to enter the car's miles/gallon and gas dollars/gallon

Calculate the gas cost for 20 miles, divide 20 by miles_gallon and multiply the result by dollars_gallon, then print it

Calculate the gas cost for 75 miles, divide 75 by miles_gallon and multiply the result by dollars_gallon, then print it

Calculate the gas cost for 500 miles, divide 500 by miles_gallon and multiply the result by dollars_gallon, then print it

5 0
2 years ago
Ian’s photography teacher asks him to take some photos of a few different species over the weekend. Which group of photos would
alina1380 [7]
I think it’s b or d..............
5 0
3 years ago
Nathan would like to save his PowerPoint presentation as a video that can be replayed easily on any device at full quality. Whic
valentina_108 [34]

Answer:

Presentation Quality

Explanation:

It will be full quality as it is from when your presenting

6 0
3 years ago
State one way the projector can be integrated into teaching and learning ​
koban [17]

Answer:

The projector con be used to show videos or pictures on a particular subject or topic to gain more understanding

4 0
3 years ago
Other questions:
  • How might your use of computers and knowledge of technology systems affect your personal and professional success?
    14·1 answer
  • In Windows Vista, the Run command can be found in which application?
    6·1 answer
  • While performing Before Operations PMCS, you notice the front right tire appears slightly underinflated. What is the proper acti
    11·1 answer
  • Please help me with question 1!
    8·2 answers
  • How are programs and algorithms related? A program is a part of an algorithm. They are not connected at all. An algorithm is a p
    12·1 answer
  • ................. are used to summarize data (option) (a) report (b) action ​
    12·2 answers
  • How does a programmer use digital waves to transfer sound?
    11·1 answer
  • State and explain three importance of internet education​
    7·2 answers
  • True or false a mirrorless camera has a pentaprism
    14·2 answers
  • Refund please, this has not helped at all.
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!