c program, Computer Engineering

program for finding the area under the curve

 

#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

Posted Date: 9/2/2012 1:22:00 AM | Location : United States







Related Discussions:- c program, Assignment Help, Ask Question on c program, Get Answer, Expert's Help, c program Discussions

Write discussion on c program
Your posts are moderated
Related Questions

Q. Define the Bandwidth of a monitor? Bandwidth is the amount of signal the monitor can handle and it is rated in MHz .This is the most usually quoted specification of a monito

Q. What do you mean by Data Distribution? Data distribution directives tell compiler how program data is to be distributed among memory areas connected with a group of processo

2. The Turing test has often been incorrectly interpreted as being a test of whether or not a person could distinguish between responses from a computer and responses from a person

Q What is Cable Modem? One more way of accessing Internet currently being developed is use of cable modems. These require that you subscribe to a cable service as well as allow

The excess 3 code of decimal number 26 is ? Ans. (26) 10 in BCD is (00100110) BCD Add 011 to all BCD 01011001 for excess - 3

Draw the logic circuit using minimizaed equation by K-map for the simplified function using NOR gates only. F (A, B, C, D) = Π M (1, 2, 3, 8, 9, 10, 11,14) ⋅ d (7, 15) Ans

Design a serial 2’s complementer with a shift register and a flip-flop

Uniform Memory Access Model (UMA) In this model, the main memory is uniformly shared by all processors in multiprocessor systems and each processor has equal access time to sha

Q. Define a Formal System? A Formal System is one which is planned in advance and is used according to schedule. In this system procedures and policies are documented well in a