variables | Sololearn: Learn to code for FREE!



when you write int a = 100; a = 50; cout << a; the answer is 50 so.. why you should still type 100 on (int a=)

4/25/2017 3:06:34 AM

agung pramudji

5 Answers

New Answer


you could initialize the number to the variable when you declare your variable or later depending on the program


to add.... if you cout<<a without loading it with a=50, it will display 100...this code is showing like chris said, that you can temporarily change whats inside "a" if you need to later, or leave it with the current value


You can also write it as int a; a=50; cout<<a; It is not necessary to declare at the time of declaration.


You can just type "int a;". No necessary to initialize it with a value in this case.


thanks all