Boolean10. Two integers are given: A, B. Check the truth of the statement: "Exactly one of the numbers A and B is odd."

Solution in Python 3:

import random
A = random.randrange(1,10)
B = random.randrange(1,10)
print("A = ", A)
print("B = ", B)
a1 = (A%2)==1
b1 = (B%2)==1
x = (a1 != b1)
print("A is odd: ", a1)
print("B is odd: ", b1)
print("Exactly one of the numbers A and B is odd: ", x)

Solution in C++:

#include <iostream>
using namespace std;
int main(){
int a, b;
cout << "Enter the number A: ";
cin >> a;
cout << "Enter the number B: ";
cin >> b;
cout << "Exactly one of the numbers A and B is odd: " << ((a%2==1) != (b%2==1)) << "." << endl;
return 0;
}