In: Computer Science
Create and call a function that prints out a favorite quotation of yours and cites the original source. Be sure to use quotes (") around the quotation and make sure the quotes are also printed out, along with the name of the source on the next line, tab indented. "You must be the change you wish to see in the world." – Gandhi.
The programming language is not mentioned in the problem. Therefore, the chosen programming language is C++.
Please specify the programming language with the problem.
Screenshot of the code:
Sample Output:
Code To Copy:
//Include the header file.
#include <iostream>
using namespace std;
//Define the function to display the quote
//with quotes and the source in the next
// line-tab intended.
void display_quote(string s, string source)
{
//Display the quote under the double quotes.
cout <<"\"" << s << "\"" << endl;
//Display the source of the quote in the next line.
//If wanted to be in the same line, remove
//the endl of the above statement.
cout << "- " << source << endl;
}
//Define the main function.
int main() {
//Declare the variables.
string str, source;
//Prompt the user to enter the quote.
cout << "Enter the Quote: ";
getline(cin, str);
//Prompt the user to enter the source.
cout << "Enter the source: ";
getline(cin, source);
//Call the function to display the quote and the source.
display_quote(str, source);
//Return the value for the main function.
return 0;
}
//For any query, please comment. Ready to help!. Kindly give positive ratings.