- 1
What is the purpose of using cin ? Where we need to use cin?
I am a beginner
7 Réponses
+ 3
It is used for input , like if you want a number from user then you can use cin.
#include <iostream>
#include<string.h>
using namespace std;
int main() {
char name[30];
cout<<"Enter the name:";
cin>>name;
return 0;
}
+ 3
To execute or run a program,you need input,sometimes input is given by default during coding time.
for eg:
int x=10;
cout<<x; //to print x on the output screen
But sometimes the user using it need to enter the value,then cin is used for that purpose!
int x;
cout<<"enter x"<<endl;
cin>>x; /*any int value can be entered here unlike the above example, where it only takes 10*\
cout<<x;
+ 2
Look at the code above,
You can understand easily
+ 2
For input data
+ 2
Thankyou for give me answer
+ 2
Cin takes input from console and store it in the variable.
0
Very useful