In the next program, I use the two functions prd () and display (). I did not declare any of them before main () before calling them in main (), and I defined it as after main (). while prd () runs smoothly inside main (), the calling display () shows the warning "The previous implicit declaration" display "was here." What is different from display (), that there is a warning for it, but not for other prd () functionality? I have not announced any of them to start with. If there is a warning due to calling one, but the other works fine.
#include<stdio.h> int main() { int x=8,y=11; printf("The product of %d & %d is %d",x,y,prd(x,y)); display(); return 0; } int prd(int x,int y) { return x*y; } void display() { printf("\n Good Morning"); }
PS: And I would really appreciate it if you could answer this secondary question: "Is a function declaration not necessary at all in C if there is a definition for it?". I have the habit of declaring all program functions before the main () function, and then defining them after the main () function. Am I mistaken?
source share