Q:

Write a C++ program to check if a given array of integers and length 2, contains 15 or 20

0

Write a C++ program to check if a given array of integers and length 2, contains 15 or 20

Sample Output:

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 nums[]) {
    return nums[0] == 15 || nums[0] == 20 || nums[1] == 15 || nums[1] == 20;
    }

int main () {
  int nums1[] = { 12, 20 }; 
  int nums2[] = { 14, 15 };
  int nums3[] = { 11, 21 };
  cout << test(nums1) << endl;
  cout << test(nums2) << endl;
  cout << test(nums3) << 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