Search
 
SCRIPT & CODE EXAMPLE
 

CPP

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 << '
';
    return 0;
}

Enter a number: 4
You entered 4
Comment

PREVIOUS NEXT
Code Example
Cpp :: C++ Vector Iterator Syntax 
Cpp :: check if set contains element c++ 
Cpp :: function c++ 
Cpp :: c++ public class syntax 
Cpp :: cudamemcpy 
Cpp :: factorial function c++ 
Cpp :: rotate array cpp 
Cpp :: c++ print binary treenode 
Cpp :: c++ modulo positive 
Cpp :: c++ double is nan 
Cpp :: How to write into files in C++ 
Cpp :: sizeof’ on array function parameter ‘arr’ will return size of ‘int*’ [-Wsizeof-array-argument] 
Cpp :: how to convert ascii to char in cpp 
Cpp :: unreal engine c++ 
Cpp :: c++ struct 
Cpp :: #define online judge in cpp 
Cpp :: c++ cout without include iostream 
Cpp :: factorial calculator c++ 
Cpp :: opengl draw semi circle c++ 
Cpp :: position of max element in vector c++ 
Cpp :: getline 
Cpp :: input full line as input in cpp 
Cpp :: attention nlp 
Cpp :: How to turn an integer variable into a char c++ 
Cpp :: convert all strings in vector to lowercase or uppercase c++ 
Cpp :: kmp algorithm c++ 
Cpp :: find pair with given sum in the array 
Cpp :: fill vector with zeros c++ 
Cpp :: heredar constructor c++ 
Cpp :: c++ map lookup 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =