Answer to Question #276253 in C++ for zain

Question #276253

Programming Problem I ( class, stack, Linked list )

You are required to find out whether the number entered by user have length even or odd. You cannot use the modulus function, modulus operator or length function


1
Expert's answer
2021-12-06T19:23:06-0500
#include <iostream>
using namespace std;
 
// Returns true if a is even otherwise it returns odd
bool isEven(int a)
{
    bool isEven = true;
    for (int i=1;  i <= a; i++)
        isEven = !isEven;
    return isEven;
}
int main()
{
    int a = 101;
    isEven(a) ? cout << "Even" : cout << "Odd";
    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