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
Step2247 [10]
3 years ago
13

In C++ write a program that prints out PI as a type double and a type float EXACTLY as shown below. Your program should have ONE

cout statement within a loop which alters the width and precision each time through the loop. Do not write 10 separate cout statements for this problem. Show the output in a table that increases the precision from 1 to 10 as shown below. Use dash ('-') as the fill character. Note the differences as the precision gets larger.
Use the following two variables for PI.

double PI_D = 3.14159256359;
float PI_F = 3.14159256359;
Computers and Technology
1 answer:
victus00 [196]3 years ago
3 0

Answer:

#include<iostream>

#include<iomanip>

using namespace std;

int main()

{

double PI_D = 3.14159256359;

float PI_F = 3.14159256359;

cout<<"i"<<"\t\t"<<"Float"<<"\t\t"<<"Double"<<endl;

for(int i = 1; i<=10;i++)

{

 cout<<i<<"-\t\t"<<PI_F<<setprecision(i)<<"-\t\t"<<PI_D<<setprecision(i)<<endl;

}

 return 0;

}

Explanation:

See Attachment where I used comments for explanation

Download cpp
You might be interested in
To format a picture to look like a sketch or a painting you can add a(an)
Arisa [49]

Answer:

C(reflection effect)

Explanation:

reflection effect

8 0
2 years ago
Write a program that plays the popular scissor-rockpaper game. (A scissor can cut a paper, a rock can knock a scissor, and a pap
kolbaska11 [484]

Answer:

import random

computer = random.randint(0, 2)

user = int(input("scissor (0), rock (1), paper (2): "))

if computer == 0:

   if user == 0:

       print("The computer is scissor. You are scissor too. It is a draw")

   elif user == 1:

       print("The computer is scissor. You are rock. You won")

   elif user == 2:

       print("The computer is scissor. You are paper. Computer won")

elif computer == 1:

   if user == 0:

       print("The computer is rock. You are scissor. Computer won")

   elif user == 1:

       print("The computer is rock. You are rock too. It is a draw")

   elif user == 2:

       print("The computer is rock. You are paper. You won")

elif computer == 2:

   if user == 0:

       print("The computer is paper. You are scissor. You won")

   elif user == 1:

       print("The computer is paper. You are rock. Computer won")

   elif user == 2:

       print("The computer is paper. You are paper too. It is a draw")

Explanation:

*The code is in Python.

Import the random to be able to generate number number

Generate a random number between 0 and 2 (inclusive) using randint() method and set it to the computer variable

Ask the user to enter a number and set it to the user variable

Check the value of computer the computer variable:

If it is 0, check the value of user variable. If user is 0, it is a draw. If user is 1, user wins. If user is 2, computer wins

If it is 1, check the value of user variable. If user is 0, computer wins. If user is 1, it is a draw. If user is 2, user wins

If it is 2, check the value of user variable. If user is 0, user wins. If user is 1, computer wins. If user is 2, it is a draw

8 0
2 years ago
Both Saturn Technologies and Granite Inc. incur a cost of $200 to manufacture a single unit of a cell phone. However, Saturn Tec
Ghella [55]

Answer:

<em> It implies that Saturn Technologies creates more economic value than Granite Inc. does</em>

Explanation:

<em>Economic value is a measure of the benefit provided by a good or service to an economic agent. It is generally measured relative units of currency, and the interpretation is therefore: what is the maximum amount of money a specific actor is willing and able to pay for the good or service?</em>

5 0
3 years ago
Add criteria to this query to return only the records where the value in the SubscriptionType field is Self or Family and the va
miss Akunina [59]

Click Run in the Results group under the Design tab. Only show records in the search results that have a Credits field value greater than 120. To see the results, run the query. Click the criterion row for the Credits field and enter >120.

<h3>The meaning of the criterion =200</h3>

Equal to or less than 200. To compute statistics like Sum, Average, or Count, add a Total row to the query datasheet.

<h3>How may criteria be set in an Access query?</h3>

Open the query in Design view and choose the fields (columns) you want to set criteria for in order to add criteria to an Access query. Double-click the field to add it to the design grid if it isn't already there.

To know more about criterion row visit:-

brainly.com/question/7301380

#SPJ4

4 0
1 year ago
How to trap a private number​
Papessa [141]

Answer:

Explanation:

       ?

4 0
2 years ago
Read 2 more answers
Other questions:
  • You're working at a large industrial plant and notice a tag similar to the one shown in the figure above. Which of the following
    5·1 answer
  • There is a simple pattern for determining if a binary number is odd. What is it and why does this pattern occur
    6·2 answers
  • A strategic business unit​ (SBU) of a major corporation has high market share in its​ industry, but the growth rate of the indus
    8·2 answers
  • Steps to customize theme of desktop
    5·2 answers
  • Experienced students may serve as mentors if they are at least age 21 and have at least 3 years of post-secondary education. In
    5·1 answer
  • Write a simple hello world program in python 3
    8·2 answers
  • A network administrator is reviewing a network design that uses a fixed configuration enterprise router that supports both LAN a
    8·1 answer
  • In what ways do you think the media should function in a democratic society?
    9·1 answer
  • Define the term algorithm and describe how programmers use algorithms when designing a program.
    13·1 answer
  • What is a megavirus in computing
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!