Home > Back-end >  Call a function within the function where the wrong ah, how to change? Bosses can be solved?
Call a function within the function where the wrong ah, how to change? Bosses can be solved?

Time:11-05

#include
using namespace std;
Double scircle (double r)
{
Return r * r * 3.14;
}
Double vcolumn (double h)
{
Return scircle (double r) * h;
}
Int main ()
{
Double r1, h1;
Cin> R1 & gt;> H1.
Coutreturn 0;
}

CodePudding user response:

 # include 
using namespace std;
Double scircle (double r)
{
Return r * r * 3.1416;
}
Double vcolumn (double r, double h)
{
Return scircle (r) * h;
}
Int main ()
{
Double r1, h1;
Cin> R1 & gt;> H1.
Coutreturn 0;
}
//input:
//1 2
//the output:
//3.1416
//6.2832

CodePudding user response:

 
Double vcolumn (double h)
{
Return scircle (double r) * h;
}

Scircle vcolumn function call function, need to pass parameters, such as scircle you (h)

CodePudding user response:

Double vcolumn (double h)
{
Return scircle (double r) * h;//scircle calls to pass arguments.
}

CodePudding user response:

Double vcolumn (double h), lack of the parameters of r. modified as follows:
 double scircle (double r) 
{
Return r * r * 3.14;
}

Double vcolumn (double h, double r)
{
Return scircle (r) * h;
}

Int main (int arg c, char * argv [])
{
Double r1, h1;
Cin> R1 & gt;> H1.
Coutreturn 0;
}

CodePudding user response:

When call don't need to write type return scircle (r) * h;

CodePudding user response:

Thank you for your bosses
  • Related