c++ input integer code example
Example 1: how to print a string to console in c++
// Just some basic format
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "Print a String" << endl;
}
Example 2: take integer input in c++
#include <iostream>
using namespace std;
int main() {
//Declare an int variable
int a;
//take input using the standard cin operator
cin >> a;
//display the integer
cout << a;
return 0;
}
Example 3: get data from terminal c++
int i;
cout << "Please enter an integer value: ";
cin >> i;