Question

1. Write a program that asks the user to enter two integers, obtains the numbers from...

1. 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.” Use only the single-selection form of the if statement you learned in this chapter.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>

using namespace std;

int main(){
   int n1,n2;
   
   cout<<"Enter nunmber1: ";
   cin>>n1;

   cout<<"Enter nunmber2: ";
   cin>>n2;   
   
   if(n1 > n2){
      cout<<n1<<" is larger"<<endl;
   }
   else if(n1 < n2){
      cout<<n2<<" is larger"<<endl;
   }
   else{
      cout<<"These numbers are equal"<<endl;
   }
   
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
1. Write a program that asks the user to enter two integers, obtains the numbers from...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ program that does the following: Asks the user to enter 3 integers, Obtains...

    Write a C++ program that does the following: Asks the user to enter 3 integers, Obtains the numbers from the user, Prints the largest number and then the smallest of the numbers, If the numbers are equal, prints the message: "These numbers are equal." Prints the sum, average, and product of the 3 numbers.

  • Write a java program that asks the user to enter 2 integers, obtains them from the...

    Write a java program that asks the user to enter 2 integers, obtains them from the user, determines if they are even or odd numbers and prints their sum, product, difference, and quotient (Division).

  • Write an application that asks the user to enter two integers, obtains them from the user...

    Write an application that asks the user to enter two integers, obtains them from the user and prints their sum, product, difference and quotient (division).(i.e. Scanner, nextInt and printf) (this has to be in java) Enter·first·integer:31 ·Enter·second·integer:69 ·31+69=100 31*69=2139 31-69=-38 31/69=0

  • C++ Write a program that prompts the user to enter integers or a sentinel to stop....

    C++ Write a program that prompts the user to enter integers or a sentinel to stop. The program prints the highest and lowest numbers entered, the sum and the average. DO NOT USE ARRAYS, only variables and loops. Write a program the prompts the user to input a positive integer. Keep asking the user until a positive integer is entered. Once a positive integer is entered, print a message if the integer is prime or not. (NOTE: A number is...

  • Write a program that asks the user to enter 1000 integers to be stored in an...

    Write a program that asks the user to enter 1000 integers to be stored in an array called "numbers". Since the same integer might occur (exist) in the array multiple times, your program needs to fill a second array, called "Isolate" that contains all the integers from the first array but NOT REPAPTED (every integer will exist only once). Finally, your program will print the integers of the second array sorted by occurrence (occurrence is: the number of times the...

  • Write a program that obtains two numbers from the user and displays the larger of the...

    Write a program that obtains two numbers from the user and displays the larger of the two numbers. Use if-else

  • Write a Java program that: • Asks the user to enter the number of integers that...

    Write a Java program that: • Asks the user to enter the number of integers that he need to enter; • Asked him to enter integer by integer; • Print The number of Odd numbers entered and the number of Even numbers entered. Important notes: 1. You should have to copy and paste the Java as your answer for this question. DON’T take screen shot for your Java Code. It must be editable. 2. Take a screen shot for your...

  • Write an assembler program that asks the user (as shown below) for two integers and a...

    Write an assembler program that asks the user (as shown below) for two integers and a single character representing the arithmetic operations: addition, subtraction, multiplication and integer division (displays both quotient and remainder). Perform the requested operation on the operands and display the result as specified below. Assume SIGNED NUMBERS. The program should not divide by 0! If the user attempts to divide by 0, display the error message: "Cannot divide by zero." If this error occurs, the program should...

  • Write a C++ program that asks the user to enter a single number from 1 to...

    Write a C++ program that asks the user to enter a single number from 1 to 50 and a choice of "even" or "odd". Using a recursive function, output the sum of all the even or odd integers from 1 up to (and including) that number. Your program does not need to loop and accept more input (only one input of the number then even/odd).

  • Write a C program that asks the user to enter three numbers (integres). A menu will...

    Write a C program that asks the user to enter three numbers (integres). A menu will be displayed to let the user choose one of the three options: print the two highest numbers, product of the three numbers or the division of the second by the by the third if the third is not zero. See the sample runs. Required: Your code must use -One function to get the numbers from the user One function for each of the three...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT