prog4_02.cpp

来自「一本语言类编程书籍」· C++ 代码 · 共 22 行

CPP
22
字号
// Program 4.2 Using an if statement
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

int main() {
  cout << "Enter an integer between 50 and 100: ";

  int value = 0;
  cin >> value;

  if(value < 50)
    cout << "The value is invalid - it is less than 50." << endl;

  if(value > 100)
    cout << "The value is invalid - it is greater than 100." << endl;

  cout << "You entered " << value << endl;
  return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?