I've taken a Java course and am trying to teach myself C with K&R. So far so good but I don't understand the purpose of prototypes. See the 2 // comments in the code below:
#include <stdio.h>
float convert(int); **//Why is this needed...**
main()
{
int i;
for(i = 0; i <= 300; i += 20)
printf("F: %3d C: %6.1f\n",i,convert(i));
system("Pause");
return 0;
}
float convert(int f) **//When we already have this?**
{
float c = (5.0/9.0) * (f-32.0);
return c;
}
In Java, you'd declare a function something like public static float convert(int f)
and not need a prototype at all. That seems much simpler to me. Why the difference?