Q5. (10 points) complete the C++ program with a function called `odd_even()` that accepts an integer argument and displays whether the passed integer is even or odd. (Hint: Use the % operator) //program `findAbc` #include "stdafx.h" #include <iostream> using namespace std; void `odd_even`(int); // function declaration. int main() { double num1; cout << "enter"; `odd_even`(num1); // main() makes function call return 0; // main() ended } void `odd_even`(num1)// this is function header { if else return; }
Added by Tracy T.
Close
Step 1
First, we need to include the necessary header file, which is <iostream>. Show more…
Show all steps
Your feedback will help us improve your experience
Patricia Holmes and 98 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
write a program to find whether a given number is odd or even. The program should continue as long as the user wants? use c++ program
James K.
Define a program to find out whether a given number is even or odd. Use function and name the function EO and it returns nothing. The function accepts one argument and its type is an integer in C++
Willis J.
Issue: My Results produce an Endless loop Question: A loop that reads positive integers from standard input and terminates when it reads an integer that is not positive. After the loop terminates, it prints out the sum of all the even integers read and the sum of all the odd integers read (The two sums are separated by a space). Declare any variables that are needed. My Code: int x; int evenSum = 0; int oddSum = 0; cin >> x; while (x > 0) { if ((x % 2) == 0 && (x > 0)) { evenSum += x; } else { oddSum += x; } cout << evenSum << " " << oddSum; }
Henry R.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD