< Back

Pc5-Ex. 1.3: Print "Hello, World" with standard output.

#include <iostream>
int main(){
    std::cout << "Hello, World, Again" << std::endl;
    return 0;
}

Pc5-Ex. 1.4: Use the multiplication operator to print the product of two numbers.

#include <iostream>
int main(){
    int v1, v2;
    std::cin >> v1 >> v2;
    std::cout << v1 * v2;
    return 0;
}

Pc5-Ex. 1.5: Rewrite the program so that the printing operation for each operand is placed in a separate statement.

#include <iostream>
int main(){
    int v1, v2;
    std::cin >> v1 >> v2;
    // std::cout << "The sum of " << v1 << " and " << v2
    //           << " is " << v1 + v2 << std::endl;
    std::cout << "The sun of ";
    std::cout << v1;
    std::cout << " and ";
    std::cout << v2;
    std::cout << " is ";
    std::cout << v1 + v2;
    std::cout << std::endl;
    return 0;
}