如何在 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
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP