I'm writing a program to calculate the first 10 multiples of the absolute value of (x^2 - 20). Everything seems to be working fine except that I'm getting parse and compile errors on my for loop, and it's driving me insane tryig to figure out what isn't working.
Any help is appreciated. Here's the code ...
#include <stdio.h>
float numsquared( float ) ;
float abs_value( float ) ;
int main()
{
float x, xsq, abval, multiple ;
int counter = 1 ;
printf( "Given x, I will calculate the first 10 multiples\n" ) ;
printf( "of the absolute value of (x-squared - 20).\n" ) ;
printf( "Please enter the value of x: " ) ;
scanf( "%f", &x );
xsq = numsquared( x ) ;
abval = abs_value( xsq ) ;
for (counter <= 10)
{
multiple = abval*counter ;
counter++ ;
printf( "%f\n", multiple ) ;
}
printf( "Thank you!\n\n" ) ;
return 0 ;
}
float numsquared( float num )
{
float square ;
square = num*num ;
return square ;
}
float abs_value( float numsq )
{
float check = 0 ;
float abs_val = 0 ;
check = numsq-20 ;
if (check >= 0)
abs_val = check ;
else
abs_val = check*(-1) ;
return abs_val;
}