(Odd or Even) Write a program that reads an integer and determines and prints whether it is odd or even. [Hint: Use the modulus operator. An even number is a multiple of two. Any multiple of two leaves a remainder of zero when divided by 2.]
What will be an ideal response?
#include
using namespace std; // program uses names from the std namespace
int main()
{
int number; // integer read from user
cout << "Enter an integer: "; // prompt
cin >> number; // read integer from user
if ( number % 2 == 0 )
cout << "The integer " << number << " is even." << endl;
if ( number % 2 != 0 )
cout << "The integer " << number << " is odd." << endl;
} // end main
You might also like to view...
In general, linked lists allow:
a. Insertions and removals anywhere. b. Insertions and removals only at one end. c. Insertions at the back and removals from the front. d. None of the above.
The most common type of query is a(n) ________ query
Fill in the blank(s) with correct word
?The _____ grouping element contains content that is quoted from another source, often with a citation and often indented on a page.
A. ?hgroup B. ?blockquote C. ?pre D. ?list
What is measured by a worst-case analysis?
What will be an ideal response?