Prints the numbers 1 to 4 on the same line with each pair of adjacent numbers separated by one space. - C++ Language Basics

C++ examples for Language Basics:Console

Description

Prints the numbers 1 to 4 on the same line with each pair of adjacent numbers separated by one space.

Demo Code

#include <iostream>

int main(int argc, const char *argv[]) {
    std::cout << "1 2 3 4" << std::endl;
    std::cout << "1 "
              << "2 "
              << "3 "
              << "4 " << std::endl;
    std::cout << "1 ";
    std::cout << "2 ";
    std::cout << "3 ";
    std::cout << "4 " << std::endl;

    return 0;//from  ww  w . j a v a2 s . co m
}

Result


Related Tutorials