Learning C here, and I’m pretty confused on how to use function prototypes.
I’m mainly having a problem calling the function into main. I’m sure I have something messed up in here because all this does is print whatever’s in memory.
Thank you for the help.
#include <stdio.h>
double source_volt(double vs);
int main()
{
double source_volt(double vs);
double vs;
printf("%lf", vs);
return 0;
}
double source_volt(double vs)
{
int valid = 0;
do
{
printf("Enter source voltage Vs in volts: ");
scanf("%lf", &vs);
if (vs < 0 || vs > 100)
{
valid = 0;
printf("Please enter a number between 0 and 100.\n");
}
else
valid = 1;
}while(!valid);
return vs;
}
This is what is not working for you:
Instead:
But really, you don’t need an argument at all in source volt.
You could rewrite that function to: