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
Middleware for cloud database applications is commonly written as ____—short sections of code written in a programming or script
Ostrovityanka [42]
<span>Middleware for cloud database applications is commonly written as scripts—short sections of code written in a programming or scripting language that are executed by another program. A script language is used for server side scripting language that can change a specific data on the server. Examples of these are PHP, JSP, Perl, Python, etc.</span>
5 0
4 years ago
By default, headers and footers apply to
AleksAgata [21]
Hold up I know he answer
6 0
3 years ago
Brainly Question 2.0
Klio2033 [76]

Answer:

Depends, but most of the time definitly  

:)

3 0
3 years ago
How do I make my own extension for chrome?
Alexeev081 [22]
Open your browser and click the 3 strip bar in the conner and then look toward the bottom and click settings and it will open a new browser and then you are going to look at the left side and you will see extension click it and there you go...

4 0
3 years ago
The trigonometry book says: sin^2(t) + cos^2(t) = 1 Write a Python program that verifies the formula with the help of the Python
MAXImum [283]

Answer:

If you open your python-3 console and execute the following .py code you will have the following output. (Inputing 20 e.g)

Write the angles in degrees: 20

radian angles is:  0.3490658503988659

cosene( 0.3490658503988659 ) =  0.9396926207859084

sine( 0.3490658503988659 ) =  0.3420201433256687

sin^2( 0.3490658503988659 ) + cos^2( 0.3490658503988659 ) =  1.0

Explanation:

Code

import math

for i in range(1,4):

   angle = int(input('Write the angles in degrees: '))

   #mat library better works with radians

   angle_radians = (angle*math.pi)/180

   #print output

   print('radian angles is: ',angle_radians)

   print('cosene(',angle_radians,') = ',math.cos(angle_radians))

   print('sine(',angle_radians,') = ',math.sin(angle_radians))

   res = (math.sin(angle_radians))**2 + (math.cos(angle_radians))**2

   print('sin^2(',angle_radians,') + cos^2(',angle_radians,') = ',res)

6 0
3 years ago
Other questions:
  • Due to the shift from host-based networks to microcomputer based networks, more than _____ percent of most organizations' total
    8·1 answer
  • Assume the integer variable num has been assigned a valid value. What is the purpose of the following code segment?
    14·1 answer
  • Nina is explaining the SQA process to her friend Amanda.
    9·1 answer
  • Darian has a gourmet cupcake business and needs a website to compete with the other bakeries in his area. He has a Google My Bus
    15·1 answer
  • Which of the following lists contains the five essential elements of a computer? Group of answer choices: 1. inputs, returns, pr
    11·1 answer
  • A(n) ___________________ process is initiated by individuals who are subjected to forensic techniques with the intention of hidi
    6·1 answer
  • Complete the below function which dynamically allocates space to a 3d array of doubles, initializes all values to 0, and returns
    8·1 answer
  • A tablet computer is a low-cost, centrally managed computer with no internal or external attached drives for data storage.
    10·1 answer
  • How are procedural and object-oriented programming approaches similar?
    14·1 answer
  • What starts with p and ends with orn
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!