如何在 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