bool in cpp code example
Example 1: c++ boolean
bool isCodingFun = true;
bool isFishTasty = false;
cout << isCodingFun;
cout << isFishTasty;
Example 2: how to initialize a boolean in c++
bool b1 = true;
Example 3: bool function in c++
bool Divisible(int a, int b) {
return (a % b) == 0;
}
Example 4: bool function in c++
bool Divisible(int a, int b) {
int remainder = a % b;
if(remainder == 0) {
return true;
} else {
return false;
}
}
Example 5: bool function in c++
bool Divisible(int a, int b) {
return !(a % b);
}