Question

C++ Language Branching Determine if numbers are equivalent. a) Request two floating point numbers from the...

C++ Language

Branching

Determine if numbers are equivalent.

a) Request two floating point numbers from the console.
b) If the numbers are equivalent, output that they are equivalent.

c) If the numbers are not equivalent, output the larger number.

Example output 1 (input is bold and italicized):

Enter two numbers: 10.2 8.5

10.2 is the larger number.

Example output 2 (input is bold and italicized):

Enter two numbers: 5 5

5 is equivalent to 5.

Homework Answers

Answer #1
#include<iostream>
using namespace std;
int main()
{
    float x, y;
    
    cout<<"Enter two numbers: ";
    cin>>x>>y;
    
    if(x==y){
        cout<<x<<" is equivalent to "<<y<<"."<<endl;
    }
    else if(x>y){
        cout<<x<<" is the larger number."<<endl;
    }
    else{
        cout<<y<<" is the larger number."<<endl;
    }
    return 0;
}

Know the answer?
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
Similar Questions
1. A Palindrome is a word that is the same backwards as it is forwards. For...
1. A Palindrome is a word that is the same backwards as it is forwards. For example, the words kayak and madam are Palindromes. a. Request an 5 character value from the console. b. If the input string is not 5 characters, print that the word is not a 5 character word and exit. c. If the input string is 5 characters, determine if the word is or is not a Palindrome. Hint: String indexes can be used to compare...
Output each floating-point value with two digits after the decimal point, which can be achieved as...
Output each floating-point value with two digits after the decimal point, which can be achieved as follows: printf("%0.2lf", yourValue); (1) Prompt the user to enter five numbers, being five people's weights. Store the numbers in an array of doubles. Output the array's numbers on one line, each number followed by one space. (2 pts) Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 142.0 Enter weight 4: 166.3 Enter weight 5: 93.0 You entered: 236.00 89.50 142.00...
(C language) <stdio.h> decisions (else if or switch) Write a program to calculate the average of...
(C language) <stdio.h> decisions (else if or switch) Write a program to calculate the average of the 2 highest numbers entered. Ask the user to enter 3 integers, determine which 2 integers are the 2 highest, and then calculate and display the average of the 2 highest numbers. Format the answer to 2 decimal places. The numbers can be entered in any sequence - lowest to highest, highest to lowest, or completely random. A decision block will be necessary to...
1.Write pseudocode for a program that allows the user to input two numbers (X and Y)...
1.Write pseudocode for a program that allows the user to input two numbers (X and Y) and a code C. If the code has value 1, the program should output the larger of X and Y and otherwise output the smaller. Now convert your pseudocode to an assembly language program. Enter the program into the lab software assembler. Assemble the program and execute it with different input data. 2. Write pseudocode for a program that allows the user to input...
IN C LANGUAGE This program initially reads two integers from standard input: (1) an integer T...
IN C LANGUAGE This program initially reads two integers from standard input: (1) an integer T and (2) a positive integer N. It then reads N integers and counts the numbers that are greater than T and the numbers than are less than T. It then prints out these two counts. Example What is the threshold value? 7 How many values? 5 Enter 5 values: 6 7 9 9 8 3 values are greater than 7 1 values are less...
5.34 Write a function statement() that takes as input a list of floating-point numbers, with positive...
5.34 Write a function statement() that takes as input a list of floating-point numbers, with positive numbers representing deposits to and negative numbers representing withdrawals from a bank account. Your function should return a list of two floating-point numbers; the first will be the sum of the deposits, and the second (a negative number) will be the sum of the withdrawals. >>> statement([30.95, -15.67, 45.56, -55.00, 43.78]) [120.29, -70.67]
(Write in C++) Write a program that reads in two numbers and, if the input is...
(Write in C++) Write a program that reads in two numbers and, if the input is valid, outputs 2 times the product of the integers that lie between the two values (including the values themselves). If either number is not an integer, or if the first number is not less than the second number, just output an error message. The sample runs below should give the idea. User inputs are in bold. Important Notes: Your program should use a loop...
A particular Instruction Set Architecture (ISA) has four classes of instruction: load/store, fixedpoint, floating-point, and branching....
A particular Instruction Set Architecture (ISA) has four classes of instruction: load/store, fixedpoint, floating-point, and branching. Load/store instructions all require 2 clock cycles to execute, fixed-point instructions all execute in one clock cycle, floating-point instructions all require 8 clock cycles to execute, and branch instructions take one clock cycle if the branch is successful and two clock cycles if the branch fails. A program is run on a processor with this ISA and measurements show that 20% of the instructions...
1. Write down the binary expansion of 50.5. 2. Consider the gaps between representable floating-point numbers....
1. Write down the binary expansion of 50.5. 2. Consider the gaps between representable floating-point numbers. Which of the following has the larger gap between it and the next larger representable floating-point number? • 2 • 201 3. Suppose that you approximate a number y by a number x. We will say that x approximates y to k decimal places if the decimal expansions of roundk(x) and roundk(y) match, where roundk(·), for the purposes of this problem, indicates rounding to...
Assembly Language Programming create an .asm [assembly language program file, using Microsoft Visual Studio or equivalent...
Assembly Language Programming create an .asm [assembly language program file, using Microsoft Visual Studio or equivalent Windows32 integrated development environment (IDE)] program into one that inputs two positive integers, and outputs their greatest common divisor, by implementing the following pseudo-code: input num1 and num2 (assume num1 > 0 and num2 > 0) gcd := num1 remainder := num2 repeat numerator := gcd gcd := remainder remainder := numerator % gcd until (remainder == 0) output gcd The following 3 windows...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT