• Advertisement

Archived

This topic is now archived and is closed to further replies.

Returns

This topic is 5938 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Guest Anonymous Poster
They also return a result for non-void functions.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
#include
#include

bool do_stuff(string name)
{
if(name == "Alex")
return true;
else
return false;
}

void main(void)
{
char tmp[50];
cout<<"Enter your name:\n";
cin.get(tmp,50);

if(do_stuff(tmp))
cout<<"Your cool!\n";
else
cout<<"You Suck!!!!";
}

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
#include
#include

bool do_stuff(string name)
{
if(name == "Alex")
return true;
else
return false;
}

void main(void)
{
char tmp[50];
cout<<"Enter your name:\n";
cin.get(tmp,50);

if(do_stuff(tmp))
cout<<"Your cool!\n";
else
cout<<"You Suck!!!!";
}

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Oops, didn''t mean to post it twice!

Share this post


Link to post
Share on other sites
Here''s an example:

  
int main()
{

int x = decideX();

}

int decideX()
{

return 3;

}


Main calls on decideX, which returns 3. 3, being the result of decideX, is assigned to the int variable x. Control is returned to main().

Share this post


Link to post
Share on other sites

  • Advertisement