Menu
Coddy logo textTech

Getting Numbers

Part of the Fundamentals section of Coddy's C++ journey — lesson 39 of 74.

challenge icon

Challenge

Beginner

Now that we have a welcome message, it's time to get the numbers for our calculations. In C++, we use the std::cin object to get input from the user. For our calculator, we need two numbers to perform operations like addition, subtraction, multiplication, and division.

Modify the given code to get two double numbers from the user and store them in variables named num1 and num2. Use std::cin to read the numbers. After getting the numbers, print them to the console using std::cout with the following format:

First number: [first number]
Second number: [second number]

Try it yourself

#include <iostream>

int main() {
    std::cout << "Calculator App" << std::endl;
    return 0;
}

All lessons in Fundamentals