Hi, I really cant see what I have done wrong here. I have never used default arguments before and I am wondering what I am doing wrong in this program.
My C compiler is complaining that my function prototype is wrong. Here is the error:
ERR1: conflicting types for 'volume'
ERR2:"an argument type that has a default promotion can't match an empty parameter name list declaration"
To be fair I have never seen that error message before and I am confused by the meaning of it.
Here is the code in question:
Code:
#include <stdio.h>
/*function prototype*/
float volume ( float height = 10.12, float width = 10.12, float length = 10.12 );
/*main function - begins program execution -----------------------------------*/
int main ( void )
{
printf("Default volume is %.2f", volume());
printf("\nAltered height rest default volume is: %.2f", volume ( 12.10 ));
printf("\nAltered height and width volume is: %.2f", volume ( 12.10, 14.20 ));
printf("\nAll default values altered volume is: %.2f", volume ( 12.10, 14.20, 16.11));
getchar(); /*freeze console output window*/
return 0; /*return value from int main*/
}
/*function to calulate volume of cube*/
float volume ( float h, float w, float l )
{
return h * w * l;
}