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
In-s [12.5K]
3 years ago
5

I want to write a C++ program to read the diameter of a circle. The program should find and display the area and circumference o

f the circle. Define a constant of type double PI = 3.14159
I need code for this program
Computers and Technology
1 answer:
Andreas93 [3]3 years ago
7 0

Answer:

#include <iostream>

const double PI = 3.14159;

int main() {

   double diameter;

   std::cout << "Please enter the diameter of the circle:" << std::endl;

   std::cin >> diameter;

   double radius = diameter / 2;

   double area = radius * radius * PI;

   double circumference = 2 * radius * PI; // or diameter * PI;

   std::cout << "Area: " << area << std::endl;

   std::cout << "Circumference: " << circumference << std::endl;

}

Explanation:

The first line imports the read/write library. The rest should be self-explanatory.

std::cin is the input stream - we use it to get the diameter

std::cout is the output stream - we write the answers (and commentary) there.

std::endl is the special "character" informing the output stream that we want it to put a newline character (and actually print to the output - it might have been holding off on it).

the // in the circumference computation signifies a comment - the program simply ignores this. I've added it to tell the reader that the circumference could have been computed using the diameter,

You might be interested in
Edhesive assignment 1 movie ratings
Oliga [24]

Answer:

ok

Explanation:

3 0
3 years ago
Explain the correct ways of using keyboard. .​
Naily [24]

Answer:

https://www.digitalunite.com/technology-guides/computer-basics/using-computer/how-use-computer-keyboard

Explanation:

the link at the top should explain it all! :)

7 0
3 years ago
Due largely to the prevalence of reading them on screens rather than in​ print, the body text of most contemporary documents now
Stella [2.4K]
.The answer is <span>sans serif. </span>Utilize sans serif textual styles in light of the fact that the close uniform width of the strokes keeps the text style intelligible when lessened in determination or diminished in text dimension. Sans serif textual styles are more clear from more distant away, which is the reason they are useful for blurbs and slides, especially the titles and headers.
4 0
4 years ago
Given a vector of students, the function FinalAvg is supposed to return the average final exam score across all the students in
alexandr1967 [171]

Answer:

The C++ code is given below with appropriate comments

Explanation:

#define CATCH_CONFIG_MAIN //This tells Catch to provide a main()

#include"catch.hpp" //Header for Catch Framework

double FinalAvg( vector <int> students) // Function to calculate average.

{

double sum =0;

int i;

for( i=0;i<v.size();i++) sum+= v[i];

return v.empty() ? 0.0 : (double(sum)/ v.size());

}

vector<int> func(int argvq[ ]) // This function is made because we can not provide vector in command line argument that's why we used array which is then conerted into vector.

{

vector<int> v;

int j;

int l= sizeof(argvq)/sizeof(argvq[0]);

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

v.push_back(argq[j]);

return v;

}

TEST_CASE(" Final Average marks are computed","[func]") // TEST_ CASE macro to take one or more arguments

{

REQUIRE( func(9,5,-7) == 7); // We write our individual test assertions using the REQUIRE macro.

REQUIRE(func(2,4,6,-2) ==4);

}

Explanation Using different IDE:

#include<bits/stdc++.h>

using namespace std;

double FinalAvg(vector<int> students)

{

double sum=0;

for(int i=0;i<v.size();i++) sum+= v[i];

return v.empty() ? 0.0 : (double(sum)/v.size());

}

int main()

{

vector<int> v;

int i;

while(cin>>i&&i>0) v.push_back(i);

cout<<Final Avg(v);

return 0;

}

8 0
3 years ago
Write at least 4 sentences
elixir [45]

Answer:

I don't know who advance the evolution who is it!

8 0
3 years ago
Other questions:
  • Write a method that checks whether the input string or a sentence (a string with spaces) is a palindrome or not. The method shou
    13·1 answer
  • Which process refers to starting up a computer?
    9·2 answers
  • Which of the following provides astronomical evidence for the age of the earth?
    11·1 answer
  • Analyst is investigating proxy logs and found out that one of the internal user visited website storing suspicious java scripts.
    8·1 answer
  • I have $80 and I want a smartphone that you can call for free what should I get
    14·2 answers
  • . Let F(X, Y, Z)=(X + Y + Z)(X + Y + Z)(X + Y + Z)(X + Y + Z). Use a 3-variable K-Map to find the minimized SOP form of this fun
    15·1 answer
  • Which stage of the waterfall model is most like the simple model's stage 5?
    12·1 answer
  • What is the importance of different camera angles ?
    9·2 answers
  • Why is it easier to spot a syntax error than a logical error?​
    10·2 answers
  • A data analyst adds descriptive headers to columns of data in a spreadsheet. How does this improve the spreadsheet?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!