+ 2
variables
when you write int a = 100; a = 50; cout << a; the answer is 50 so.. why you should still type 100 on (int a=)
5 Respostas
+ 4
you could initialize the number to the variable when you declare your variable or later depending on the program
+ 3
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
+ 2
You can also write it as
int a;
a=50;
cout<<a;
It is not necessary to declare at the time of declaration.
0
You can just type "int a;". No necessary to initialize it with a value in this case.
0
thanks all