anu, Computer Engineering

Assignment Help:

write a program to find the area under the curve y=f(x) between x=a and y=b integrate y=f(x) between the limits of a and b. the area under a curve between two points can be found by doing a definite integral between a to points.

 

#include 
float
    start_point,            /* GLOBAL VARIABLES */

end_point, total_area; int numtraps; main( ) { void input(void ); float find_area(float a,float b,int n); /* prototype */
print(“AREA UNDER A CURVE”); input( ); total_area = find_area(start_point, end_point, numtraps); printf(“TOTAL AREA = %f”, total_area); } void input(void ) { printf(“\n Enter lower limit:”); scanf(“%f”, &start_point); printf(“Enter upper limit:”); scanf(“%f”, &end_point); printf(“Enter number of trapezoids:”); scanf(“%d”, &numtraps); } float find_area(float a, float b, int n) { float base , lower, h1, h2; /* LOCAL VARIABLES */
float function_x(float x); /* prototype */
float trap_area(float h1,float h2,float base );/*prototype*/
base = (b-1)/n; lower = a; for (lower =a; lower <= b-base ; lower = lower + base ) { h1 = function_x(lower); h1 = function_x(lower + base ); total_area += trap_area(h1, h2, base ); } return (total_area); float trap_area(float height_1,float height_2,float base ) { float area; /* LOCAL VARIABLE */
area = 0.5 * (height_1 + height_2) * base ; return (area); } float function_x(float x) { /* F(X) = X * X + 1 */
return (x*x + 1); } Output AREA UNDER A CURVE Enter lower limit: 0 Enter upper limit: 3 Enter number of trapezoids: 30 TOTAL AREA = 12.005000 AREA UNDER A CURVE Enter lower limit: 0 Enter upper limit: 3 Enter number of trapezoids: 100 TOTAL AREA = 12.000438


Related Discussions:- anu

Addressing relationship for main memory and cache, Q. Addressing Relationsh...

Q. Addressing Relationship for Main Memory and Cache? In the normal case there are 2k words in cache memory and 2n words in main memory. The n-bits memory address is splitted i

What is input - output instructions, Q. What is Input - Output Instructions...

Q. What is Input - Output Instructions? An I/O instruction is stored in memory of computer and is fetched as well as executed by processor producing an I/O-related command for

Explain handlers classification, Handlers Classification In 1977, Wolfg...

Handlers Classification In 1977, Wolfgang Handler suggested a complex notation for representing the pipelining and parallelism of computers. Handler's categorization addresses

Registers used in organisation of an associative memory, In the organisatio...

In the organisation of an associative memory, many registers are used: Comparand Register (C): This register is used to grasp the operands, which are being searched for, or

Determine the decimal equivalent of hexadecimal number, The hexadecimal num...

The hexadecimal number for (95.5) 10 is ? Ans. (95.5) 10 = (5F.8) 16 Integer part Fractional part 0.5x16=8.0

Logical difference among move a to b and compute b = a, What is the  logic...

What is the  logical difference among Move A TO B and COMPUTE B = A ? Ans) In case of Move A TO B it will move whatever the value of a in to b. It mean it will move nume

Classification of parallel computers , Classification Of Parallel Computer...

Classification Of Parallel Computers  Introduction Parallel computers are those that underline the parallel processing among the operations in some way. In the last unit,

What is strong-typing versus weak-typing, What is strong-typing versus weak...

What is strong-typing versus weak-typing? Which is preferred? Why? Strong type is checking the types of variables as early as possible, usually at compile time. Whereas weak ty

For what DMSP stands, For what DMSP stands? DMSP stans here for Dist ri...

For what DMSP stands? DMSP stans here for Dist ributed Mai l system Protocol.

How do you classify the neutrons, Q. How do you classify the neutrons in te...

Q. How do you classify the neutrons in terms of its kinetic energy? Neutrons are classified as-per to their kinetic energy as (a) Slow neutrons as well as (b) fast neutrons.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd