Print Friendly and PDF
(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.
(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.


Solution: 

a) cout << "1 2 3 4";

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

c)cout << "1 ";

cout << "2 ";

cout << "3 ";

cout << "4 ";

zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: