+ 2
Why we use my variable command ??
I can also use cout <<" 10"; for 10 out put
4 odpowiedzi
+ 7
you can just cout << "10" but what if instead of 10 you wanted to see the results of 10 times a number which is entered by the user of your program?
+ 4
I don't know
+ 2
If a program only has constant numbers, it wouldn't be called a program. It would be more like a document.
0
You definitely can, and for a simple program like in the example your way might even be better. Variables are really nice if you want them to change later. For example:
int moneyInWallet = 0;
int deposit = 10;
moneyInWallet = moneyInWallet + deposit;
cout << moneyInWallet << endl;
//moneyInWallet is now 10
variables are also really nice for readability. I don't know about you but numbers are to mathy for me. I'de rather my programs read as close to english as possible.
Later edit -> When you're using cout << "10"; you are console logging the ***string*** 10. . . you want to console out the ***integer*** 10.
"10"+"10" = 1010
10 + 10 = 20