Answer to Question #201454 in C++ for shuvo

Question #201454
Write a function called is even() that has a single statement. That statement is a return statement that returns a bool value. The function has just one parameter of type int
1
Expert's answer
2021-06-04T06:07:52-0400
#include <iostream>

bool is_even(int n)
{
    return n % 2 == 0;
}

int main()
{
    std::cout << "Is 2 an even number? " << (is_even(2) ? "Yes" : "No") << "\n";
    std::cout << "Is 3 an even number? " << (is_even(3) ? "Yes" : "No") << "\n";
    
    return 0;    
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog