0
I dont understand how to write cin code and use it
2 Réponses
+ 1
cin is the C standard input, and is used to take in information from the user and save it to a variable.
For example, asking the user's name:
int age;
cin >> age;
cout << "You are " << age << " years old!\n";
What this will do is wait for the user to input a number, and save that number to the age variable. We then print out age using cout.
When taking input in the form of a string, it's best to use getline(cin, str).
string name;
getline(cin, name);
cout << "Your name is " << name << "!";
0
#include <iostream.h>
#include <condo. h>
int main ()
{
int a;
cout <<"enter a number";
cin>>a;
cout <<"number you entered is="<<a;
return 0;
}
so we use cin to take input from the user by using keyboard when we run code