area under the curve, C/C++ Programming

program area under the curve y=f(x) between x=a & y=b, integrate y=f(x) between the limits of a & b



float    start_point,            /* GLOBAL VARIABLES */

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)
      floatbase, lower, h1, h2;    /* LOCAL VARIABLES */
float function_x(float x);    /* prototype */
float trap_area(float h1,float h2,floatbase);/*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);
    float trap_area(float height_1,float height_2,floatbase)
       float area;    /* LOCAL VARIABLE */

       area = 0.5 * (height_1 + height_2) * base;
    float function_x(float x)
         /* F(X) = X * X + 1 */
return(x*x + 1);

    Enter lower limit: 0
    Enter upper limit:  3
    Enter number of trapezoids: 30
    TOTAL AREA   =  12.005000

    Enter lower limit: 0
    Enter upper limit: 3
    Enter number of trapezoids: 100
    TOTAL AREA = 12.000438

Posted Date: 9/3/2012 1:32:04 AM | Location : United States

Related Discussions:- area under the curve, Assignment Help, Ask Question on area under the curve, Get Answer, Expert's Help, area under the curve Discussions

Write discussion on area under the curve
Your posts are moderated
Related Questions
Jewels can only be removed for polishing from either end of the necklace

Array of Objects: The objects can be declared just like a structure or even a primary data type.  Array of objects may be required to work with large set of data.   When the da

Give practice in writing program''s..

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers

Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

With this assignment you will build a toy program that manipulates pointers to integers. You will develop the same main program fragment in both C and Assembler. Thus, you'll get t

Write a simple program in C++ to investigate the safety of its enumeration types. Include at least 10 different operations on enumeration types that are incorrect/unsafe things to

Structure of C++ Program: Chronological order of C++ program. 1.   Class declaration 2.   Main function program 3.   Member functions definitions 4.   Include heade

Hi, I want to get rtsp source for windows