Question

write the C++ program to do the following 1. read in 2 numbers as ints 2....

write the C++ program to do the following

1. read in 2 numbers as ints

2. calculate the sum, difference, product, and quotient

3. print out the four calculated numbers in the following  

    format

          the two input numbers are ??? and ???

             sum is             ????

             difference is     ????

             product is        ????

             quotient is       ?????.??????

where ??? represents the ints and ????.???? represents the decimals. You can have any number of decimal places

Example:

Assume your 2 input numbers are 6 and 7

The output should look like

          the two input numbers are 6 and 7

             sum is             13

             difference is     -1

             product is        42

             quotient is       0.85714285

use your 'PLAN'

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include<bits/stdc++.h>

using namespace std;

int main()
{
//initializes two variables of integer type
int num1,num2;
cin>>num1>>num2;//takes input from user
cout<<"the two input numbers are "<<num1<<" and "<<num2<<endl;
cout<<"sum is "<<num1+num2<<endl; //calculates the sum of two numbers
cout<<"difference is "<<num1-num2<<endl; //calculates the difference of two integers
cout<<"product is "<<num1*num2<<endl; //calculates the multiplication of two integers
float quotient=float(num1)/float(num2); //we explicitly converted it to float to get the float result,otherwise we would have got an integer result
cout<<"quotient is "<<quotient<<endl;
  
}

Add a comment
Know the answer?
Add Answer to:
write the C++ program to do the following 1. read in 2 numbers as ints 2....
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
  • C++ program by using while loop structure. Write an interactive program (C++) to prompt and read...

    C++ program by using while loop structure. Write an interactive program (C++) to prompt and read two float type numbers, Then your program should perform and print the following arithmetic: (use while loop structure to repeat program 2 times. 1) Sum 2)Difference 3) Product 4) Quotient 5) Modulus (use system defined fmod function) You must use system's defined function prototype and/or to create programmer's defined function prototype for each of the above calculation. In addition, create a function called "DISPLAYLINE...

  • Write a program in c++ that generates a 100 random numbers between 1 and 1000 and...

    Write a program in c++ that generates a 100 random numbers between 1 and 1000 and writes them to a data file called "randNum.dat". Then re-open the file, read the 100 numbers, print them to the screen, and find and print the minimum and maximum values. Specifications: If your output or input file fails to open correctly, print an error message that either states: Output file failed to open Input file failed to open depending on whether the output or...

  • in Java and also follow rubric please 4. Write a complete program to do the following:...

    in Java and also follow rubric please 4. Write a complete program to do the following: Using an input and output files, write a program that will read 20 numbers from an input file called InFile. Sum all even numbers and multiply all odd numbers. Print the numbers read from the input file to an output file called OutFile. Also print the sum of the even numbers and the product of the odd numbers to the output file. Rubric: •...

  • Language is C programming Student ID should be 8 numbers long. create a program to read...

    Language is C programming Student ID should be 8 numbers long. create a program to read your student ID number and store it in an array. Input can not be hard wired, I have to be able to input my number Then change the first number to a letter. If the same number repeats in other parts of your student ID, you must change that number to a letter as well. print original array and modified array as your output....

  • C- PROGRAMMING PROJECT #4 Design and Write a C program to calculate an average of an...

    C- PROGRAMMING PROJECT #4 Design and Write a C program to calculate an average of an array of numbers and produce the following output: 1. Your first and last name 2. Course Number 3. C Project Number 4. All the numbers in the array 5. The sum of all the numbers in the array 6. The count of all the numbers in the array 7. The average of all the numbers in the array Double-space after lines 3, 4, 5,...

  • in c++ please HW09: Read/Write File Ints Now that we've had a taste of what file...

    in c++ please HW09: Read/Write File Ints Now that we've had a taste of what file I/O is all about, here's your chance to try it out on your own! You're to write a program that will prompt the user if he/she would like to read ints from a file (and have them displayed to stdout) or write ints to a file for safekeeping. If the user wishes to save a set of numbers, then the file nums.txt is opened...

  • C Programming Write a program that meets the following requirements: • Your program will read three...

    C Programming Write a program that meets the following requirements: • Your program will read three integer values from the keyboard. • Your program will output the following data in this order: 1. The third divided by the first if the first is not zero. 2. The third divided by the second if the first is zero and the second is not zero. 3. The sum of the first, second and third values. • All numbers are integers and only...

  • Use C++ Read numbers from a file and find the sum of numbers. Perform the following...

    Use C++ Read numbers from a file and find the sum of numbers. Perform the following operations Read the console input and create a file.txt. $ in the console input is considered as an end of content for a file. Close the file after creation. Open the file in a read mode and read the numbers from a file and print the sum of all numbers. Input 77 124 2333 $          Where $ indicate an end of console input...

  • C Programming For this task, you will have to write a program that will prompt the...

    C Programming For this task, you will have to write a program that will prompt the user for a number N. Then, you will have to prompt the user for N numbers, and print then print the sum of the numbers. For this task, you have to create and use a function with the following signature: int sum(int* arr, int n); Your code should look something like this (you can start with this as a template: int sum(int* arr, int...

  • Write a C program named assignment04.cpp that will ask for and read in a float for...

    Write a C program named assignment04.cpp that will ask for and read in a float for a radius ask for and read in a float for the height each of the following functions will calculate some property of a shape (area, volume, circumference, etc) The functions will accept one or two parameters (radius and/or height) and return the proper calculation. There is no input/output (cin or cout) in the function – just the calculation write the following functions float areaCircle(float...

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