+ 1

use of cin

what is the difference between storing of some value using "cin" extraction and declaring the value initially like " int a=2"

2nd Aug 2017, 1:44 PM
Mukesh Chandra
Mukesh Chandra - avatar
5 Answers
+ 18
int a=2;. //is assignment at the time of declaration while int a; cout<<"enter a no"; cin>>a; //is taking the value from user at time of execution
2nd Aug 2017, 1:47 PM
P R
P R - avatar
+ 14
You use cin when you want the value to be determined by the user, instead of being initialized by the programmer.
2nd Aug 2017, 1:46 PM
Hatsy Rei
Hatsy Rei - avatar
+ 1
If you declare a value like that, it will be a static value defined at compile time. Usually, the users don't have access to the code so they can change the value and compile again. It is also bothersome for users.
2nd Aug 2017, 3:10 PM
Denis Felipe
Denis Felipe - avatar
+ 1
cin is used to put the value according to your demand and nothing else.
2nd Aug 2017, 4:33 PM
Irwin Lopez
Irwin Lopez - avatar
+ 1
cin means console input. It is used to get input from the user.
18th Aug 2017, 2:11 PM
Tayo
Tayo - avatar