1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sliva [168]
3 years ago
6

Write a program that requires the user to enter two floating-point numbers (num1 and num2) from the keyboard. Multiply them and

display the original two numbers and the calculated floating-point product. When displaying the floating-point numbers, limit your output display to 3 digits after the decimal point (for example, display 23.567810 as 23.568).
Computers and Technology
1 answer:
kogti [31]3 years ago
5 0

Answer:

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

   float num1,num2,product;

   cout<<"Input first number: ";

   cin>>num1;

   cout<<"Input second number: ";

   cin>>num2;

   product = num1*num2;

   int digits = 3;

  cout << " (rounded to " << digits << " digits after the decimal point )"<< fixed << setprecision(digits) << num1 << "*" << num2 <<  " = " << product << "\n";

   

   return 0;

}

Explanation:

iostream is a standard library file that contains code that allows a C++ program to display output on the screen and read input from the keyboard.

iomanip is a standard library used for formatting your output.

using namespace std means that you are going to use classes or functions  from "std" namespace,

int main() is used as the entry point of the program, it contains your code and the  main() is the function from where the program will start to execute.

float num1,num2,product;

you have to first declare the variables and assign them to a data type float.

   cout<<"Input first number: ";

   cin>>num1;

   cout<<"Input second number: ";

   cin>>num2;

prompt and collect inputs for num1 and num2

product = num1*num2;

calculate the product of num1 and num2

int digits = 3;

the number of digits you want after the decimal point

cout << " (rounded to " << digits << " digits after the decimal point )"<< fixed << setprecision(digits) << num1 << "*" << num2 <<  " = " << product << "\n";

fixed ensures that the precision that you have set will remain constant through out the code.

setprecision(digits)  this allows you to set the precision

You might be interested in
Using a pin or password in addition to tpm is an example of what type of authentication?
anzhelika [568]
Considering it is private i would say security?
3 0
3 years ago
Which of the following should get a Page Quality (PQ) rating of Low or Lowest?
Luda [366]

Answer:

A page that gets a Didn't Load flag

Pages with an obvious problem with functionality or errors in displaying content

Explanation:

The main reason why a page gets Page Quality rating Low/Lowest is if it can't be shown for one reason or another.

A page with mismatch between the location of the page and the rating location, does have a mismatch but some form of a page is shown.

A file type other than a webpage displays that specific file type in a page framework, so page is shown

Other two do not show a page, so they will get a PQ rating Low/Lowest

7 0
3 years ago
__ is/are the amount of blank space between lines of text in a paragraph
Natali [406]
Indents? Double Space? one of those
5 0
3 years ago
Read 2 more answers
On a client/server network, data does not necessarily follow the same path between the request (client) and the response (server
Andrej [43]

Answer:

SSL and HTTPS play a factor

6 0
2 years ago
How to enhance the video to full screen in filmora
Anastaziya [24]

Answer:

The answer to your question is to click on the button with the square on the window options ribbon.

6 0
3 years ago
Other questions:
  • When desktop publishing software can interact with another software program, the two are said to
    6·1 answer
  • Help plz
    5·1 answer
  • Consider the following program segment: //include statement(s) //using namespace statement int main() { //variable declaration /
    9·1 answer
  • Refer to the exhibit. A network security analyst is using the Follow TCP Stream feature in Wireshark to rebuild the TCP transact
    8·1 answer
  • What is Automation ? Please give an example ?
    14·1 answer
  • Please help me. Adnan also wants to add a photograph of a bridge. It is on another PowerPoint presentation that is open in a dif
    11·1 answer
  • State the functions of all the parts of the computer​
    14·1 answer
  • What is the principal goal of data science?<br>​
    5·1 answer
  • The small flash memory used in<br>protable device like Laptop<br><br>​
    10·1 answer
  • Hi everyone can anyone tell me how to align the photo the right in code.org
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!