Tuesday 21 July 2020

 2.17 (Printing) Write a program that prints the numbers 1 to 4 on the same line with each pair of adjacent numbers separated by one space. Do this several ways: A. Using one statement with one stream insertion operator. B. Using one statement with four stream insertion operators. C. Using four statements.
a) cout << "1 2 3 4";

b) cout << 1 << 2 << 3 << 4;

c)cout << "1 ";

cout << "2 ";

cout << "3 ";

cout << "4 ";

No comments:

Post a Comment