Get a copy of the is_even.cpp file by: --------------------------- -------------
ID: 3844852 • Letter: G
Question
Get a copy of the is_even.cpp file by:
---------------------------
----------------------------
Entering the cp command: cp /net/data/ftp/pub/class/110/ftp/cpp/is_even.cpp is_even.cpp
or, using your mouse to copy and paste the program into Pico, or
using the Hercules command-line ftp program to copy this file from the CS Department's anonymous ftp site.
The purpose of this program is to practice using user defined functions.
Add code to the program to complete it.
Compile and run this C++ program.
The program output should look like the following:
Explanation / Answer
I have completed that function is_even
#include <iostream>
using namespace std;
void is_even(int); // Function Prototype
int main( )
{
int num;
cout << "Enter an integer: ";
cin >> num;
cout << "Is " << num << " even? ";
is_even(num);
cout << endl;
return 0;
}
// "is_even" function.
// Prints "yes" if a is even, "no" otherwise.
void is_even(int a)
{
if(a%2 ==0)
{
cout<<"yes";
}
else{
cout<<"no";
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.