0

I dont understand how to write cin code and use it

2nd Aug 2016, 1:39 PM
Shweta Agarwal
Shweta Agarwal - avatar
2 Antworten
+ 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 << "!";
2nd Aug 2016, 4:30 PM
Cohen Creber
Cohen Creber - avatar
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
3rd Aug 2016, 7:40 PM
sachin tomar
sachin tomar - avatar