#include
Float calc_bmi (float height, float weight) {
Float bmi;
(a) (calculate bmi)
Return (bmi);
}
Int main (void) {
Float height, weight, bmi;
Printf (" height ");
The scanf (" % f, & amp; Height);
Printf (" weight ");
The scanf (" % f ", & amp; Weight);
(b) (BMI) was calculated by the function calc_bmi;
Printf (" BMI is % f ", BMI);
}
2
PI=4 * (1-1/3 + + 1/9-1/5-1/7 1/11 +... + (1) ^ n - 1/(2 n - 1)
N=1000, write approximately equal to PI program
Thank you very much!
CodePudding user response:
The first topic, BMI is: weight/height ^ 2, know this subject can write, do youThe second question: write a recursive with respect to OK, pass n to recursive function, the return value x 4
CodePudding user response:
1, (a) statement: bmi=height/weight; What bmi representative here, I am assuming that is divided by the weight, height(b) statement: bmi=calc_bmi (height, weight);
The scanf (" % f, & amp; Height); Inside the parentheses "less % f", the correct is: the scanf (" % f ", & amp; Height);
2,
# include & lt; stdio.h>
#include
#include
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# pragma argsused
Int main (int arg c, char * argv [])
{
Int s=1;
Float n=1, t=1, PI=0;
While (n
=1000){
PI=PI + t;
N=n + 2;
S=-s;
T=s/n.
}
PI=PI * 4;
Printf (" PI=% f \ n ", PI);
Cin> s;
return 0;
}
CodePudding user response:
Second question of the algorithm, and should be more accurate:# include & lt; stdio.h>
#include
#include
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# pragma argsused
Int main (int arg c, char * argv [])
{
Int s=1;
Float n=1, t=1, PI=0;
While (n
=1000){
++n;
PI=PI + t;
S=-s;
T=s/(2 * n - 1);
}
PI=PI * 4;
Printf (" PI=% f \ n ", PI);
//cin> s;
return 0;
}
CodePudding user response: