I'm trying to find the product of two numbers using a function which receives the values of two variables from main() and the address of the variable prd where the product will be stored.
I can't get this compiling because i get the following errors from Visual Studio C++ 2010 Express Edition:
f_p.c(13): error C2440: 'function' : cannot convert from 'float *' to 'float'
f_p.c(13): warning C4024: 'product' : different types for formal and actual parameter 3
f_p.c(13): warning C4028: formal parameter 3 different from declaration
Any idea where the problem might be?
I would appreciate a short explanation of what I'm doing wrong.
The code is the following:
#include <stdio.h>
#include <stdlib.h>
void product (float, int, float);
main() {
float x, prd;
int y;
printf ("Give 2 Numbers; the fist float and the second int");
scanf_s("%f %d", &x, &y);
product (x, y, &prd);
printf ("\nThe product is: %f\n\n", prd);
system("pause");
}
void product (float x, int y, float *prd){
*prd = x * y;
}