Home > Back-end >  How to get wrapped up the function of internal value
How to get wrapped up the function of internal value

Time:09-29

Void multiplication1 ()
{
Int the product;
Int multiplication1A=rand () % 10;
Int multiplication1B=rand () % 10;//set up two random number
The product=multiplication1A * multiplication1B;
Printf (" % d % d *=? The \ n ", multiplication1A, multiplication1B);//print issue
}


If I want to get the product value, how to do

CodePudding user response:

Int multiplication1 ()
{
//...
Return the product.
}

CodePudding user response:

 int multiplication1 () 
{
Int the product;
Int multiplication1A=rand () % 10;
Int multiplication1B=rand () % 10;//set up two random number
The product=multiplication1A * multiplication1B;
Printf (" % d % d *=? The \ n ", multiplication1A, multiplication1B);//print issue
Return the producet;
}

Method 1

 void multiplication1 (int * output) 
{
Int the product;
Int multiplication1A=rand () % 10;
Int multiplication1B=rand () % 10;//set up two random number
The product=multiplication1A * multiplication1B;
Printf (" % d % d *=? The \ n ", multiplication1A, multiplication1B);//print issue
* the output=the product;
}

Method 2
Pay attention to method 2 need to pass the address of a variable of type int,

CodePudding user response:

reference 1/f, play big shoot early nuclear response:
int multiplication1 ()
{
//...
Return the product.
}

Need the printf function to print first and then get the value of the pro direct return, printf is not carried out

CodePudding user response:




reference weixin_45985307 reply: 3/f
Quote: refer to 1st floor early play big play nuclear war reply:
int multiplication1 ()
{
//...
Return the product.
}

Need the printf function to print first and then get the value of the pro directly return, printf does not perform the

To return the product placed behind the printf with respect to OK,
  • Related