Answers for "how to make a user input in c++"

C++
13

user input c++

#include <iostream>
int main(){
  std::string firstname; //variable created as a string
  std::cout << "What's your first name\n";
  std::cin >> firstname;//asking for the users' first name
  std:: cout << "Hello " << firstname
}
//Works for anyone, don't need any packages, just type this is in and run it.
Posted by: Guest on June-04-2020
0

how to make a user input in c++

#include <iostream>
using namespace std;

int main() {
  int x, y;
  int sum;
  cout << "Type a number: ";
  cin >> x;
  cout << "Type another number: ";
  cin >> y;
  sum = x + y;
  cout << "Sum is: " << sum;
  return 0;
}
Posted by: Guest on September-22-2021

Code answers related to "how to make a user input in c++"

Browse Popular Code Answers by Language