Q:

Write a C++ program to check if two or more non-negative given integers have the same rightmost digit

0

Write a C++ program to check if two or more non-negative given integers have the same rightmost digit

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 x, int y, int z)
        {
           return x % 10 == y % 10 || x % 10 == z % 10 || y % 10 == z % 10;
        }
        
        
int main() 
 {
  cout << test(11, 21, 31) << endl; 
  cout << test(11, 22, 31) << endl; 
  cout << test(11, 22, 33) << 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