hihi,everyone.

As I'm just a beginner of C program, please help ^^.

I use the following program to estimate the area of

y=sqr(cos(x)p2+1)

sqr= square root,

p2 = power 2,

from x=0 to x=2.

I use a rectangle to enclose the graph with height 1.5 and width 2.0.

y<= 2 power 0.5 = 1.414 as cos(x)<=1

so i use this estimation formula:

red_area=rect*(red/total)

if y<1.414, then the pts lie in the graph.

if y>1.414, then the pts lie outside the graph.

for x between 0 and 2.0 with increment 0.00001.

and my program is the following.

# include <stdio.h>

# include <math.h>

int main(void)

{

float y,rect;

float x=0;

int total,red=0;

y=pow(pow(cos(x),2)+1, 0.5);

rect=1.5*2.0;

for (x=0; x<2; x=x+0.00001)

{

total++;

if (y<1.414)

{

red++;

}

}

printf("red area = %f \n", rect*red/total);

return 0;

}

please help me, thanks.