+ 1

What is the difference ?

int a=2 , b=3 // for example and int a,b cout<<" enter the 2 numbers"; cin>>a>>b ????

8th Nov 2016, 2:59 PM
Shaloke Chakraborty
Shaloke Chakraborty - avatar
4 Answers
+ 4
well they might be giving same output. in first example the no have same value and can be changed on the source code inside ide but the second one is better
8th Nov 2016, 3:13 PM
Sandeep Chatterjee
0
in the first you have initialised the value, and you can't change the value of variables for every program run. In the second one, input is provided at runtime which kind of makes it flexible.
8th Nov 2016, 6:36 PM
kamal joshi
kamal joshi - avatar
0
can u plz give an example !! so i can make it more clear ??
8th Nov 2016, 6:43 PM
Shaloke Chakraborty
Shaloke Chakraborty - avatar
0
See when you write "cin>>a>>b" you are entering the numbers after the program runs,i.e you can input any no and it will take those values. whereas in the first case, you have given the value a=2,b=3 before the program executes. you will have those values of a and b every time you run it.
8th Nov 2016, 6:50 PM
kamal joshi
kamal joshi - avatar