Hi.
I am new to c++ and started building a simple calculator. I did manage to make it to the easy stuff like plus, minus, multiply and devide. Now I want to add the "Square root". I have managed to make the program to square root, but my problem is that I have to enter 2 numbers (As for plus, minus, multiply and devide). So my question is: How can I make it so when I make input 5 (for square root) it will cout "Enter the number you want to square root: "? and not "Enter num 1" "Enter num 2"?
Here is my code:
You must make the distinction between operations which only require one operand and those that require two.
1 2 3 4 5 6 7 8 9 10 11 12 13
if (choice == 5)
{
//user chose square root, they only need to provide one number
cout << "\nPlease enter the number: ";
cin >> num1;
}
else
{
cout << "\nPlease enter the first number: ";
cin >> num1;
cout << "Now, please enter the second number: ";
cin >> num2;
}