Answer to Question #160465 in C++ for Paper boii

Question #160465

1. Write a function called isEven() that uses the remainder operator(%) to determine whether an integer is even or not.


1
Expert's answer
2021-02-01T22:30:02-0500

#include <iostream>


using namespace std;


bool isEven(int a){

  return a%2 == 0? true : false;

}

int main()

{

  int a;

  cout<<"Input an integer...\n";

  cin>>a;

  string str = isEven(a) ? " is even.": " is odd.";

  cout<<a<<str;


  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