Answer to Question #8873 in C++ for eva

Question #8873
Hi, I am new to c++ and have a question. In my code I need to use a variable of my void fuction in my main. A simple example is

Void sendvariable (int x)
{
Int x=2


}

Int main ()
{
…..

Want to get x from above function and do something on it

}
1
Expert's answer
2012-04-28T11:59:52-0400
You need to declare your function as int function and then return x back:


int sendvariable (){
x=2
& hellip;
return x;
}
&
Int main (){
& hellip;
int x = sendvariable ();
& hellip;
}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS