163k views
3 votes
Write a function that asks a user for his/her name and movie

watched. Then the function prints a greeting message.
A session should look like the following:
What is your name? Ahmed
Which movie have you seen? The Battle of Algiers
The printed message is: "Today, I learned that Ahmed watched
The Battle of Algiers movie!“ (Output)

User APalmer
by
6.3k points

1 Answer

1 vote

Answer:

The answer to this question is given below in the explanation section.

Step-by-step explanation:

The code is written in C++

/******************************************************************************

Online C++ Compiler.

Code, Compile, Run and Debug C++ program online.

Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

#include <string>

using namespace std;

void display()

{

string yourName;

string watchedMovie;

cout<<"What is your name? ";

cin>>yourName;

cout<<"Which movie have you seen? ";

cin>>watchedMovie;

cout<<"Today, I have learned that " <<name<<" watched "<<watchedMovie<<" movie";

}

int main()

{

display();

return 0;

}

User Abhay Koradiya
by
7.3k points