user input c 2b 2b

Solutions on MaxInterview for user input c 2b 2b by the best coders in the world

showing results for - "user input c 2b 2b"
Emanuele
27 Sep 2020
1#include <iostream>
2int main(){
3  std::string firstname; //variable created as a string
4  std::cout << "What's your first name\n";
5  std::cin >> firstname;//asking for the users' first name
6  std:: cout << "Hello " << firstname
7}
8//Works for anyone, don't need any packages, just type this is in and run it.
Adrián
18 Sep 2016
1int x; 
2cout << "hurry, give me a number!: "; // Type a number and press enter
3cin >> x; // Get user input from the keyboard
4cout << "you picked: " << x << " !" // Display the input value
5
6OR use:
7getline >> (cin, variable-name);
8instead of 
9cin >> x; 
10