Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ area under a curve for equation F(X) = 5x^3 + 7x^2 -3x+4; from 2 to 7 until the difference between the last two calculations

C++ area under a curve

for equation

F(X) = 5x^3 + 7x^2 -3x+4;

from 2 to 7

until the difference between the last two calculations is less than .0001

Why doesnt this code work?

// Source File: test.cpp // Description: calculating the area under the curve

#include #include #include //pow

using namespace std;

int main(){ double A = 0; double B = 0; double Area = 0; double height =0; double width = 0; double current_total = 0; double previous_total =0;

A = 2; B = 7; double n =10; double xpos = 0; double diff=1; double prev_width = 0; double prev_n =0; do{ //current total

width = (B - A)/n;

for(double i =0; i

Area = height * width;

current_total = Area + current_total;

} //previous total prev_width = (B - A)/(n-1); prev_n = n-1;

for(double i =0; i

Area = height * prev_width;

previous_total = Area + previous_total;

}

diff = current_total - previous_total ; n++; }while ( diff > 0.0001); cout << "Result: " << current_total << endl;

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago