Problem:
When I try to compile the program I get 3 error statements, 2 of them are relating to using the pow math function to try and square the radius variable. The last error statement states that i'm missing a semi-colon on line 11 but I don't see where. I apologize for these newbie questions, hope you can help thanks.
What I've tried:
I've tried just doing "radius * radius" to get radius^2 rather than using pow(radius, 2,0); and it works but I still get the "line 11 expected ; " error. Also for my assignment i'm required to use the pow function so its a necessity that I get that working.
My Code
#include <stdio.h> //Including standard library
double calculatingFunction(diameter) {
const double pi = 3.14159; //Declaring pi as a constant
double radius = diameter * 0.5; //Calculating radius
double circumference = 2 * pi * radius; //Calculating circumference
double area = pi * (pow(radius, 2.0)); //Calculating area
return (circumference, area); //returning values of circumference of area
}
//Beggning of main function
int main(void) {
//Prompting User for Input
printf("Please enter a value for the diameter of a circle");
double diameter; //Variable to store User's input
scanf("%lf", &diameter); //Scanning for User's input
//Final Output listing the calculated perimeter and area of circle
printf("\nPerimeter of Circle: %lf Area of Circle: %lf",
calculatingFunction(diameter));
return 0; //End of Program
}
Errors:
homework.c: In function ‘calculatingFunction’:
homework.c:8: warning: implicit declaration of function ‘pow’
homework.c:8: warning: incompatible implicit declaration of built-in
function ‘pow’
homework.c:11: error: expected ‘;’ before ‘of’
Programs purpose:
I've left comments on my code so it should be pretty clear what output is expected. The program is basically taking a user's input for the diameter of a circle and calculating the area and perimeter from it.