return statement

The return statement in Tipcontrol is used to exit a function and return a value to the function’s caller. It signifies the end of a function’s execution.

Structure of a return Statement

The basic structure of a return statement is:

Components:

  1. return Keyword: Indicates that the function is terminating.
  2. Value (required):The expression specifies what value to return. The return value does not have to be used, and typically an in other languages empty return will be return(NIL);

Simple Example

#include <stdio.h>

// Function that returns the square of a number

    result = number * number;

    return(result); // Return the calculated square, can alos use return(number*number);

// Function with no return value{

    lib.log(“Hello, World!”);

    return(NIL); // Optional, since the function is void

Explanation:

  •  The return result; statement exits the function and provides a value back to the caller, if no value is needed typically NIL is returned.