exercise 1.24 solution

#include <iostream>

using std::cout;
using std::cin;

int main() {
	int num1, num2, num3, num4;

	////////////////////////////////////////////////////////////
	// a) Using one output statement with one stream insertion operator
	////////////////////////////////////////////////////////////

	// little introduction
	cout << "Enter four integers: ";
	// read two integer
	cin >> num1 >> num2 >> num3 >> num4;

	cout << num1 << "\t" << num2 << "\t" << num3 << "\t" << num4 << "\n";

	////////////////////////////////////////////////////////////
	// b) Using one output statement with four stream insertion operator
	////////////////////////////////////////////////////////////

	cout << "Enter four integers: ";
	cin >> num1;
	cin >> num2;
	cin >> num3;
	cin >> num4;

	cout << num1 << " " << num2 << " " << num3 << " " << num4 << "\n";

	////////////////////////////////////////////////////////////
	// c) Using four output statement
	////////////////////////////////////////////////////////////

	cout << "Enter four integers: ";
	cout << 1 << " " << 2 << " " << 3 << " " << 4 << "\n";

	return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s