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
2.Use loops to create a 4X6 matrix in which the value of each element is two times its row number minus three times its column n
DiKsa [7]

Answer:

for(i=0; i<4; i++)

{

      for(j=0;j<6;j++)

      {

               A[ i ][ j ] = 2* i - 3*j;

      }

}

Explanation:

In this loop for each i = 0,1,2,3 we fill the the corresponding column values. and then move to next i value i.e. row.

3 0
3 years ago
Computers that are close to one another are connected to form a LAN
Archy [21]

Explanation:

different computer are connected to a LAN by a cable and an interface card

6 0
3 years ago
__________for about 10 minutes in between each repetition session helps you to remember the information better. a. Reading c. Sl
k0ka [10]

the answer is a.) reading

6 0
2 years ago
Read 2 more answers
What standards organization maintains the ethernet standard?.
Fofino [41]

Answer:

Ethernet standards are written and maintained by the IEEE, the Institute of Electrical and Electronic Engineers which has its corporate office in New York City and its operations center in Piscataway, New Jersey.

Explanation:

5 0
2 years ago
How many words fit on a double-spaced page?
sveticcg [70]
It depends on the length of the words.
5 0
3 years ago
Other questions:
  • Kyra needs help planning what images and text to use in her web page what technique can help her
    5·2 answers
  • 6. Write a program that can multiply an n x m matrix and m x n matrix together: The input specifications are these: Read n and m
    11·1 answer
  • Lenovo's ThinkPad laptop computers is designed in the United States, the case, keyboard, and hard drive are made in Thailand; th
    14·1 answer
  • Whitch action should a user take to ensure that formatting is applied to a row? A. use the ctrl+a keys. B. highlight the whole t
    11·1 answer
  • What are the importance of switches in our electron device
    15·1 answer
  • Vector testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full cr
    7·1 answer
  • Which is a benefit of traditional SLR cameras over digital cameras? A. They produce negatives to serve as backups. B. They make
    6·1 answer
  • Compute (110110001.01)2 + (27.12)10 + (121.25)16 – (130.20)16 and display the answer in hexadecimal base.
    7·1 answer
  • What is a sensitive compartmented information program
    12·1 answer
  • What is white light?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!