13,803,738 members
See more:
```#include <stdio.h>
#include <math.h>
int compute_polynomial (int a, int b, int c, int x){             //prototype
int fx;
fx = a* pow(x,2) + b*x + c ;
return (fx);
}
double trapezoid_area (int x1, int x2, int fx1, int fx2){        //prototype
double area;
area = (fx1 + fx2)* (x2-x1) / 2;
return (area);
}
double auc_polinomial (int a, int b, int c, int partitions, int x_low, int x_high) {        //prototype
double total_area = 0;
int x1, x2, one_partition;
int fx1, fx2;
double trap_area;
one_partition = (x_high - x_low)/ partitions;
for (x1 = x_low; x1<=x_high; x1 += one_partition){
fx1= compute_polynomial (a, b, c, x1);
for (x2= x_low + one_partition; x2<=x_high; x2 += one_partition){
fx2= compute_polynomial (a, b ,c, x2);
}
trap_area = trapezoid_area (x1,x2, fx1, fx2);
total_area += trap_area;

}
return (total_area);
}

int main (){
int a,b,c;
int x_low, x_high;
int partitions;
double total_area;

printf("Enter three polinomial coefficents in order a b c : ");
scanf("%d %d %d", &a, &b, &c);
printf("Enter x interval: ");
scanf("%d %d", &x_low, &x_high);
printf("Enter number of partitions: ");
scanf("%d", &partitions);
total_area = auc_polinomial( a, b, c, partitions, x_low, x_high);
printf(" AUC: %f", total_area);
return (0);

}```

What I have tried:

I already executed it, but the AUC result doesnt appear on the screen. I just know that there is something wrong with the "for" loop when I compile the total area.
Posted 29-Oct-17 15:05pm
Updated 30-Oct-17 0:10am
v2

## Solution 1

Quote:
I just know that there is something wrong with the "for" loop when I compile the total area.

Then use the debugger to see what your code is really doing.

There is a tool that allow you to see what your code is doing, its name is debugger. It is also a great learning tool because it show you reality and you can see which expectation match reality.
When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute.

Debugger - Wikipedia, the free encyclopedia[^]

Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
Basic Debugging with Visual Studio 2010 - YouTube[^]
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.

## Solution 2

You should revise your data type choices. For such kind of computation you should use `double` datatype for every variable.

Top Experts
Last 24hrsThis month
 OriginalGriff 220 CPallini 135 Dave Kreskowiak 105 Peter Leow 70 Richard MacCutchan 68
 OriginalGriff 3,183 Richard MacCutchan 2,321 CPallini 1,118 RickZeeland 900 Dave Kreskowiak 850