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

What is common control switching system, What is common control switching s...

What is common control switching system? Explain. Common Control Switching System: It is a functional block diagram of a common control switching system is demonstrated in figu

Incorporating javascript into a web page, As we already know, HTML (Hyperte...

As we already know, HTML (Hypertext Markup Language) is the language we use to create Web documents. Now we will read "Hello World!" As given below:

How can i handle floating-point exceptions gracefully, 'On many systems, yo...

'On many systems, you can describe a function matherr which will be known as when there are certain floating-point errors, like errors in the math routines in .

What is the system call available to change the personality, What is the sy...

What is the system call available to change the personality? The system call personality prefers to a method to modify its implementation domain in order that Linux can emulate

What is multiple interrupt lines, Q. What is Multiple Interrupt Lines? ...

Q. What is Multiple Interrupt Lines? Multiple Interrupt Lines: Simplest solution to problems above is to provide multiple interrupt lines that will result in immediate recognit

Operating systems, Consider the state transition diagram of Figure 3.9b . S...

Consider the state transition diagram of Figure 3.9b . Suppose that it is time for the OS to dispatch a process and that there are processes in both the Ready state and the Ready/S

What is the difference among character and block devices, a. What is the di...

a. What is the difference among character and block devices? b. Discuss the method to make a Kernel Driver for the PC Speaker. c. Explain the socket structure with the help o

Components of magnetic disk, Q. Components of magnetic disk? Disk itsel...

Q. Components of magnetic disk? Disk itself is mounted in a disk drive that comprises arm which is a shaft that rotates disk and the electronics required for input and output b

What is the kernel, What is the kernel?          A more common definiti...

What is the kernel?          A more common definition is that the OS is the one program running at all times on the computer ,usually  known as the kernel, with all else being

What is program-controlled i/o, What is program-controlled I/O? In prog...

What is program-controlled I/O? In program controlled I/O the processor repeatedly checks a status flags to achieve the needed synchronization among the processor and an input

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