Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

C++ Exercises: Check two given integers whether either of them is in the range 100..200 inclusive

C++ Basic Algorithm: Exercise-14 with Solution

Write a C++ program to check two given integers whether either of them is in the range 100..200 inclusive.

Sample Solution:

C++ Code :

#include <iostream>
using namespace std;

bool test(int x, int y)
        {
            return (x >= 100 && x <= 200) || (y >= 100 && y <= 200);
        }
        
int main() 
 {
  cout << test(100, 199) << endl;  
  cout << test(250, 300) << endl;  
  cout << test(105, 190) << endl;  
  return 0;    
}

Sample Output:

1
0
1

Pictorial Presentation:

C++ Basic Algorithm Exercises: Check two given integers whether either of them is in the range 100..200 inclusive.

Flowchart:

Flowchart: Check two given integers whether either of them is in the range 100..200 inclusive.

C++ Code Editor:

Contribute your code and comments through Disqus.

Previous: Write a C++ program to check if one given temperatures is less than 0 and the other is greater than 100.
Next: Write a C++ program to check whether three given integer values are in the range 20..50 inclusive. Return true if 1 or more of them are in the said range otherwise false.

What is the difficulty level of this exercise?