Answers for "c++ get input from keyboard"

C++
0

c++ output

#include <iostream>

int main(){
  std::cout << "Hello World!" << std::endl; // prints "Hello World"
}
Posted by: Guest on October-07-2020
0

C++ keyboard input

#include <iostream>  // for std::cout and std::cin
 
int main()
{
    std::cout << "Enter a number: "; // ask user for a number
 
    int x{ }; // define variable x to hold user input (and zero-initialize it)
    std::cin >> x; // get number from keyboard and store it in variable x
 
    std::cout << "You entered " << x << 'n';
    return 0;
}

Enter a number: 4
You entered 4
Posted by: Guest on June-01-2021

Browse Popular Code Answers by Language