38.7k views
23 votes
What happens when an arithmetic operator is applied to non-arithmetic data types such as Boolean or character

User Alex Riina
by
4.8k points

1 Answer

12 votes

Answer:

Following are the code to this question:

#include<iostream>//defining header file

using namespace std;

int main()//defining main method

{

bool a = true;//defining bool variable that holds true value

bool b = false;//defining bool variable that holds false value

cout<<a+b<<endl;//using print method to add bool value

cout<<a-b<<endl;//using print method to subtract bool value

cout<<a*b<<endl;//using print method to multiply bool value

return 0;

}

Output:

1

1

0

Step-by-step explanation:

In this code, Firstly we import the header file, and in the next step, the main method is defined, in this, two bool variable "a, b" is declared, that holds true and false value respectively, and in the next step, three print method is declared that adds, subtract, and multiply the given value and use print its calculated value.

User Timmos
by
3.7k points