Answer to Question #342890 in C++ for Padi

Question #342890

The post office needs a program that reads in postal address data and then displays the data in a neat format. • Declare four string variables name, addr1, addr2 and postalCode. • First, the main function of the program must input the data by means of a function called inputData. • Second, the main function calls the function displayData to display the name and address as follows: Mr R.S. Bopape P.O. Box 50741 Sandton 2146


1
Expert's answer
2022-05-26T16:55:27-0400
#include<iostream>
#include<string>
using namespace std;
    void inputData(string *name,string *addr1,string *addr2,string *postalCode){
 
     
    cout<<"Enter name  ";
    getline(cin, *name);
    
    cout<<"Enter address 1  ";
     getline(cin, *addr1);
    
    cout<<"Enter address 2  ";
      getline(cin, *addr2);

    cout<<"Enter postal code  ";
     getline(cin, *postalCode);
}
void displayData(string name,string addr1,string addr2,string postalCode) {
    cout<<"POSTAL INFORMATION"<<endl;
    cout<<name<<" "<<addr1<<" "<<addr2<<" "<<postalCode<<endl;
    }
    
int main(){
  string name, addr1, addr2, postalCode;
 
    inputData(&name, &addr1, &addr2, &postalCode);
    displayData(name, addr1, addr2, postalCode);

return 0;}

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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS