Write a program that inputs a series of integers and passes them one at a time to function even, which uses the modulus operator to determine whether an integer is even. The function should take an integer argument and return true if the integer is even and false otherwise.

What will be an ideal response?


```
// Determine whether inputs are odd or even.
#include
using namespace std;

bool isEven( int ); // function prototype

int main()
{
int x; // current input

// loop for 3 inputs
for ( int i = 1; i <= 3; i++ )
{
cout << "Enter an integer: ";
cin >> x;

// determine if input is even
if ( isEven( x ) )
cout << x << " is an even integer\n\n";
else
cout << x << " is an odd integer\n\n";
} // end for

cout << endl;
} // end main

// isEven returns true if a is even
bool isEven( int a )
{
return !( a % 2 );
} // end function isEven
```

Computer Science & Information Technology

You might also like to view...

The second step in penetration testing is ____.

A. reporting B. exploiting C. examination D. mapping

Computer Science & Information Technology

Which of the following is NOT a broadband connection to the Internet?

A) Satellite B) Dial-up C) DSL D) Fiber-optic

Computer Science & Information Technology

Which of the following is the proper method to dynamically allocate memory to an array of 100 elements?

a. ``` var c = new c[ 100 ]; ``` b. ``` var c = new c( 100 ); ``` c. ``` var c = new Array[ 100 ]; ``` d. ``` var c = new Array( 100 ); ```

Computer Science & Information Technology

Switching to Design view allows you to preview the records that will be added to the other table before actually running the query

Indicate whether the statement is true or false

Computer Science & Information Technology