i compiled a code for a class i am in and it worked but my professer said it was
ID: 3719598 • Letter: I
Question
i compiled a code for a class i am in and it worked but my professer said it was not correct although everyone I shared it with did not see a problem with it but here I am back for more help. I was told to move the defninition before int main instead of where it was before. And once I did that I am getting th following error message.
1) The function definition should be located after main. You have it before main where the prototype is needed.
2) I was told that my function has a double argument, but in my call I pass it 2 which is an integer. Need to pass it a double value
3) I also need to modify this code to prompt for and input the values I am passing to the function.
I have been trying to search the web for answer to these and none of them makes any sense to me since it is all explain in programmers language.
Explanation / Answer
#include<stdio.h>
double circleArea(double num);
int main(void){
double result;
printf("Enter the radius: ");
scanf("%lf", &radius);
result = circleArea(radius);
printf("Circle Area %lf ", result);
return 0;
}
double circleArea(double num){
double result;
result = 3.14 * num * num;
return result;
}
**Comment for any further queries.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.