Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone fix this C++ code which is suppose to read in the radius(r), the slant height(s), and the height(h) of a cone from a

Can someone fix this C++ code which is suppose to read in the radius(r), the slant height(s), and the height(h) of a cone from a file. calculate the surface area of a cone and volume of the cone. you can use random in puts.

#include

#include

using namespace std;

const float pi=3.14;

voidreadfrom(ifstream&file,float&r,float&h,float&s)

{

file>>r>>s>>h;

}

void calc(float&r, float&h, float&s,float&surfacearea, float&volume)

{

surfacearea = pi*r*s + pi*r*r;

volume = pi*r*r*h*1.0/3.0;

}

void print(float r, float s, float surfacearea, float volume)

{

printf("%0.2f\t%.2f\t%.2 2f ,r,s,h,surfacearea,volume");

}

int main()

{

double r,s,h,surfacearea,volume;

float r,h,s,surfacearea;

ifstream file;

file.open("read.text");

print("radius\t height\t surfacearea\t volume ");

read from file(file r,h);

while(!file, eof())

{

calc(r,h,s,sufracearea);

print(r,h,surfacearea,volume);

read from file(file r,h);

}

cout<< " ";

return 0;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

Discuss the five types of learner outcomes.

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago