Question

Write a C++ block of code that gets an address on three lines from the user...

Write a C++ block of code that gets an address on three lines from the user and it outputs only the second line, or the street address part of the whole address.

No loops. if or for statements -

example:

Input Output

The Number Family
789 Donaknowy Way
Big City, CA 92929

789 Donaknowy Way

The Banks
13 Cherry Tree Ln.
London, CA 92003

13 Cherry Tree Ln.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

Explanation:

Three variables of string type are declared. line1, line2, and line3.

Then , three getline function calls are used to read three lines from the user as input.

then the second line is printed using cout.

Code:


#include <iostream>

using namespace std;

int main()
{
string line1, line2, line3;
getline(cin, line1);
getline(cin, line2);
getline(cin, line3);
  
cout<<line2<<endl;
  
return 0;
}

Output:

PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!

Add a comment
Know the answer?
Add Answer to:
Write a C++ block of code that gets an address on three lines from the user...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in c++ and must use loops This block of code goes in donation_total. This block tallies...

    in c++ and must use loops This block of code goes in donation_total. This block tallies all the donations made to the local community center. The program keeps tallying donations until it gets a negative value, and then it stops. If a donation is more than $ 100, the program outputs, "Send a t-shirt". For example, Input Output 20.50 50 125 101.1 80 21-1 Send a t-shirt Send a t-shirt Total donations made $300.50 10 10 10-3 Total donations made...

  • Write C code to repeatedly ask the user for a number, then once the user enters...

    Write C code to repeatedly ask the user for a number, then once the user enters 0, the code displays the min, max and average of all values entered. To get proper credit, name the variables as listed below and follow the directions carefully. Do not use any break or similar type of statements. To implement the above code, you will need to count the entries - name the counter variable num_count. You will also need to use a variable,...

  • C++ : Please include complete source code in answer This program will have names and addresses...

    C++ : Please include complete source code in answer This program will have names and addresses saved in a linked list. In addition, a birthday and anniversary date will be saved with each record. When the program is run, it will search for a birthday or an anniversary using the current date to compare with the saved date. It will then generate the appropriate card message. Because this will be an interactive system, your program should begin by displaying a...

  • Description Write C++ code that correctly input and output information. (Moving data to and from the...

    Description Write C++ code that correctly input and output information. (Moving data to and from the screen and to and from text files. Also inputting predefined functions, etc., from included libraries.) Problem Description Consider a data file that has geometrical angle values in degrees. Angle values may be on one line, several lines, or any other white space separated format. Fig. 1 below shows one possible format, but other formats are possible. 12.9 100.8 270.5 300.6 120.8 There are no...

  • Project 4: Month-end Sales Report with array and validation Input dialog box for initial user prompt...

    Project 4: Month-end Sales Report with array and validation Input dialog box for initial user prompt with good data and after invalid data Input OK Cancel Input dialog boxes with sample input for Property 1 Ingut X Input Enter the address for Property 1 Enter the value of Property 1: OK Cancel Input dialog boxes after invalid data entered for Property 1 Error Please enter anmumber greater than D Ester the walue of Peoperty t Console output END SALES REPORT...

  • Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   please put comment with code! and please do not just copy other solu...

    Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   please put comment with code! and please do not just copy other solutions. Instructions 1. Read instructions carefully! 2. Use C++ syntax only, C syntax will not be accepted. 3. Always use braces to define blocks. 4. Indent all lines within a block. Each block requires one more tab. 5. Organize your code well with proper formatting and a single...

  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

  • John and Jane Doe are married retired taxpayers who care for their three-year-old grandson. The following...

    John and Jane Doe are married retired taxpayers who care for their three-year-old grandson. The following information was provided to you as documentation necessary to prepare their 2017 tax return. You will gather the appropriate information and complete the forms provided in Blackboard (1040, Schedule A, Schedule B and Schedule D) in preparation of their tax file. Please note that the forms provided may not match the tax year of the course, as IRS forms are not available until just...

  • Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory...

    Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory allocation) and have it pointed to by a pointer (of type int * ) named ptr_1. Use ptr_1 to assign the number 7 to that dynamically allocated integer, and in another line use printf to output the contents of that dynamically allocated integer variable. Write the code to dynamically allocate an integer array of length 5 using calloc or malloc and have it pointed...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT