如何在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
热门推荐
10 许愿星姐妹祝福语简短
11 朋友家住豪宅祝福语简短
12 舅妈生日红包祝福语简短
13 金店立秋祝福语简短英文
14 聚餐朋友喝酒祝福语简短
15 少先队代表送祝福语简短
16 俄语祝福语贺卡文案简短
17 新人给朋友祝福语简短
18 娘家妈妈新婚祝福语简短