2

C doubt

view story
linux-howto

http://forums.fedoraforum.org – Hii I have the following program . #include<stdio.h> int fun(int,int); int ring(); int main() { int y=fun(2,3); printf("%d",y); } int ring() { return 4; } int fun(int x,int y) { ring(); } The program compiled and gave output 4. I have following doubt. 1. why the C compiler doesn't give error "return statement missing in int fun() function". 2. Can we write function body with out return statement where functions are prototypically declared to return something int or char.. SECOND .. I have modified the program see below int fun(int,int); int ring(); int ping(); int main() { int y=fun(2,3); printf("%d",y); } int ring() { return 4; } int fun(int x,int y) { ring(); ping(); } int ping() { return 5; } This also compiled and gave output 5. again the same question.. How can the function fun() can take the return value of function ping() THIRD:: I have modified the program again ..see below int fun(int,int); int ring(); int ping(); int main() { int y=fun(2,3); printf("%d",y); } int ring() { return 4; } int fun(int x,int y) { ring(); ping(); printf("HIII"); } int ping() { return 5; } This also worked and the output is HIII4 here 4 is the output from printf function which returns the number of characters it printed.. 1. Can somebody throw light on what is happening also give the links or pdfs where to confirm the answer. FOURTH:: The same program modified as #include<stdio.h> double fun(int,int); double ring(); double ping(); int main() { double y=fun(2,3); printf("%f",y); //ring(); } double ring() { return 4; } double fun(int x,int y) { ring(); ping(); printf("HIIIii"); } double ping() { return 7; } compiles and gives output HIIIii7.000000 here it has taken the return value of ping not printf please clarifi these doubts. (HowTos)