Q:

Write a C++ program to check two given integers, and return true if one of them is 30 or if their sum is 30

0

Write a C++ program to check two given integers, and return true if one of them is 30 or if their sum is 30

Sample Output:

1
1
1
0

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <iostream>
using namespace std;

bool test(int x, int y)
        {
            return x == 30 || y == 30 || (x + y == 30);
        }        
        
int main() 
 {
  cout << test(30, 0) << endl;  
  cout << test(25, 5) << endl;  
  cout << test(20, 30) << endl;  
  cout << test(20, 25) << endl;    
  return 0;    
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now