by Dinesh Thakur Category: Function and Pointer

The default returns value from a function in int. In other words generally unless explicitly specified the default return value by compiler would be integer value from function. So when a programmer wants other than integer values to be returned from function then it is essential that the programmer takes some steps in doing this namely:

Mention eth return type in the calling function and Mention the return type in the called function.

Both steps 1 and 2 must be made if the return value is other programmer wants to return other than integer value from function.

Let us see how to do this with a example:


       float x=2.5,y=3.5,z;
       float sample();

       float sample(x1,y1,z1)
       float x1,y1,z1;
             float z1;
             z1= x1+ y1


Here the output would be


Here the return value is float from function sample. Therefore as said before it is declared in calling function namely main() as

float sample()

after the variable declaration in main() and it is also declared in the function sample as

float sample(x1,y1,z1)

It is vital for programmers to follow the above to have the correct return value from function.


About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Search Content

Popular Article