Question
What am I missing in my code? Question: Functions can return a string, not just an int or a float. Write a function called evenOrOdd
What am I missing in my code?
Question:
Functions can return a string, not just an int or a float. Write a function called evenOrOdd which takes an integer parameter and returns either "Even" or "Odd" based on the value passed. In main, prompt the user for a number, called num, then pass num to evenOrOdd and display the returned value on the screen. Keep doing this until the user enters a zero. Use the given template to get started. Use the following run as an example:
Enter a number: 1 is Odd Enter a number: 2 is Even Enter a number: 3 is Odd Enter a number: 4 is Even Enter a number: 5 is Odd Enter a number: 0
Code:
#include
cout
Output:
1 Compare output 3 input Enter a number: 1 is Odo Enter a number: 2 is Even Enter a number: 3 is Odd Your output Enter a number: 4 is Even Enter a number: 5 is Odd Enter a number: 0 Enter a number: 1 is Odo Enter a number: 2 is Even Enter a number: 3 is Odd Expected output Enter a number: 4 is Even Enter a number: 5 is Odd Enter a number: 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started