944,069 Members | Top Members by Rank

Ad:
Aug 22nd, 2006
0

C programming

Expand Post »
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.
Similar Threads
Reputation Points: 23
Solved Threads: 1
Newbie Poster
the.future.zone is offline Offline
15 posts
since Aug 2006
Aug 22nd, 2006
0

Re: C programming

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
Last edited by WaltP; Aug 22nd, 2006 at 5:31 am.
Moderator
Reputation Points: 3281
Solved Threads: 894
Posting Sage
WaltP is offline Offline
7,747 posts
since May 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in IT Professionals' Lounge Forum Timeline: Instant messaging
Next Thread in IT Professionals' Lounge Forum Timeline: What Caused Microsoft to Create DirectX10?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC