(Comparing Integers) Write a program that asks the user to enter two integers, obtains the numbers from the user, then prints the larger number followed by the words "is larger." If the numbers are equal, print the message "These numbers are equal."

What will be an ideal response?


```
// Exercise 2.18 Solution: ex02_18.cpp
#include // allows program to perform input and output
using namespace std;

int main()
{
int number1; // first integer read from user
int number2; // second integer read from user
cout << "Enter two integers: "; // prompt user for data
cin >> number1 >> number2; // read two integers from user

if ( number1 == number2 )
cout << "These numbers are equal." << endl;
if ( number1 > number2 )
cout << number1 << " is larger." << endl;
if ( number2 > number1 )
cout << number2 << " is larger." << endl;
} // end main
```

Computer Science & Information Technology

You might also like to view...

A worksheet inserted into a workbook using the New Sheet button is inserted ________

A) at the beginning of the Tab group B) in the middle of the Tab group C) at the end of the Tab group D) in the location designated by the user in the dialog box that appears

Computer Science & Information Technology

Format modifiers, if used, must always be placed immediately after the ____ symbol.

A. ! B. = C. % D. .

Computer Science & Information Technology

Which argument of the onItemClick method holds the value of the array element in the View adapter?

A. parent B. view C. position D. id

Computer Science & Information Technology

Suppose you want to use a for loop to iterate through an array named anArray. How would you indicate the number of times the loop will be performed?

A. final Integer N = anArray.length; for (Integer i = 0; i < N; i++) {... B. anArray.length = N; for (Integer i = 0; i < anArray.length; i++) {... C. for (anArray.length = 0; anArray.length < N; anArray.length++) {... D. final Integer N = anArray.length; for (Integer i = anArray.length; i < N; i++) {...

Computer Science & Information Technology