Originally Posted by
Sharifhs
Dear Adak, please forgive my ignorance, but just for understanding, could you tell me what is a prototype and where is it used in this program?
A prototype is setting the interface for the function before it's used. Basically it's saying what type of value the function receives(arguments), what value it returns and of course the name of the function.
As its easier to explain in code:
Code:
#include<stdio.h>
int calculator(int, int); // Prototype - returntype name(argument/s)
int main()
{
printf("Please insert two factors to multiply.\n The first:");
int factorOne, factorTwo;
scanf("d%", &factorOne);
printf("The second: ");
scanf("d%", &factorTwo);
int product = calculator(factorOne, factorTwo); // Functioncall
printf("The product of the factors multiplied is: d%", &product);
getchar();
return 0;
}
int calculator(int factorOne, int factorTwo)
{
return factorOne * factorTwo;
}