Tuesday, July 28, 2009

Gettin a warning in turbo c.?

for the foll.. progr.. in turbo c


main()


{


int p, n;


float r,si;


printf("enter p, n, r");


scanf("%d %d %f", %26amp;p, %26amp;n, %26amp;r);


si=p*n*r/100;


printf("%f", si);


}





on compiling i get a warning


'function shud return a value in function main'


can someone tell me whats wrong????

Gettin a warning in turbo c.?
http://c-faq.com/ansi/maindecl.html





There are only *two* ways you can declare main. As int main. Or in its full form, with the parameters. It is not main. It is not void main. It is not float main. It is not anything else but int main.





How you declare main is defined by the C standard. It's not Turbo C specific or visual C++ specific or gcc specific or whatever.





Because it is int main, your main function must return a value. It suffices to add return 0 to the end, until you are writing more advanced programs and the return value matters.
Reply:in turbo C.. the function return type needs to be spcified.. here instead of main if u have void main that will solve the problem


No comments:

Post a Comment