如何在C ++中读取和打印整数值
在这里,我们将看到如何从用户读取整数并以C++显示。要接受输入,我们将使用cin运算符,而要显示我们将使用cout运算符。语法类似于-
输入-
int x; cin >> x;
输出-
int x = 110; cout << x;
示例
#include<iostream>
using namespace std;
int main(int argc, char const *argv[]) {
int x;
int y = 50;
cout << "Enter some value: ";
cin >> x;
cout << "The given value is: " << x << endl;
cout << "The value of y is: " << y;
}输出结果
Enter some value: 100 The given value is: 100 The value of y is: 50