954,089 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C programming

Hi folks.
I'm just learning C language,and I always come across a statement that I have no idea what it means. What does "returning a variable" mean?
Thanks.

the.future.zone
Newbie Poster
15 posts since Aug 2006
Reputation Points: 23
Solved Threads: 1
 

When a function is finished, the final statement in the funct can be something like return x; x is the value returned into the variable.

Example:

val = add(a, b);    // add A and B
...

int add (int x, int y)  // define the add function
{
    int z;

    z = x + y;     // add the values
    return z;      // return the value of the addition
}


val will contain the sum when the function is finished.

When you get to functions you will understand -- I hope ;)

WaltP
Posting Sage w/ dash of thyme
Moderator
10,492 posts since May 2006
Reputation Points: 3,348
Solved Threads: 943
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: