CyberSlug Rules!

Beginner Programming CMPS060

Prof. Paulo Franca

Home

Syllabus

Login

Objects

Download

Staff only

How to return a value:

In order to return a value, you must do two things in your function:

  • Specify the return type in the function header.
    A return type different than "void" means the function returns a result.
  • Include in the function body at least one statement specifying which is the result you want to return.
    This is done using the keyword "return".

 Ex.

float dif(float value1,float value2);
{
return value1-value2;
}