I am just doing a revision task and was running into the error too few arguments to function, so I did some research and apparently can use NULL for the statement not in use. However, when I run my program all that happens is the prompt for the user to enter the 3 values then it ends. It doesn't perform the calculations.
Below is my code, if anyone can help with that, it would be greatly appreciated.
#include <stdio.h>
#include <stdlib.h>
float res_calculation (float r1, float r2, float r3, float* RS, float* RP )
{
*RS = (r1+r2+r3);
*RP = (r1*r2*r3)/(r1*r2+r2*r3+r1*r3);
return 0;
}
int main()
{
float r1,r2,r3,rs,rp;
printf("Please enter the values for r1, r2 and r3 seperated by a space");
scanf ("%f %f %f", &r1, &r2, &r3);
res_calculation(r1,r2,r3,&rs,NULL);
printf("%f",rs);
res_calculation(r1,r2,r3,&rp,NULL);
printf("%f",rp);
return 0;
}
NULLis a macro, not a statement.