+ 1
Whats the simplest way to make this work?
Its a very simple multiplication calculator, im new to C++ and im curious is there an easier shorter way to do this code/make it work? Thxx --------------------------------------------------------------------------------------------------------- #include <iostream> int number; int number2; int main() { std::cout << "This is a multiplication calculator, insert your first number below.\n"; std::cin >> number; std::cout << "Please put in your second number.\n"; std::cin >> number2; number *= number2; std::cout << "Your answer is " << number << std::endl; return(0); } -----------------------------------------------------------------------------------------------------------
2 ответов
+ 8
you made number and number2 globals. this is not required and considered bad practise. Especially so when there is no need to do it.
Move these variable inside main.
0
And maybe you could get the numbers with one input and then split it...