This program is to calculate BMI values. But its only getting inputs then not showing any outputs. can anyone help me with this | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

This program is to calculate BMI values. But its only getting inputs then not showing any outputs. can anyone help me with this

void CalcBMI(float weight[],float height[],float BMI[],int size) { float bmi=0; for(int i=0; i<size; i++) { bmi=weight[i]/((height[i]*0.01)*(height[i]*0.01)); cin>>BMI[i]; } } is there any wrong in this function?

17th Jun 2021, 7:23 PM
Jenshika Jeisin
Jenshika Jeisin - avatar
3 ответов
+ 3
to print anything use std::cout function of c++
17th Jun 2021, 7:28 PM
Prashanth Kumar
Prashanth Kumar - avatar
+ 2
Hi! You trye to solve BMI project? Or something else?
17th Jun 2021, 7:38 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 2
there's many mistakes in few lines of code :D assuming the function is designed to handle arrays of height and weight values and print each pair bmi: 1) you doesn't need to have a BMI array argument, as you doesnt return values (and if you expect to read the modified array outside of the function, you must pass it by reference rather than by value) 2) you use 'bmi' local variable to store each bmi's values 3) you use height values divided by 100 (multiplied by 0.01) then squared: which unit is supposed to be populated your height array? ... as bmi formula is weight (kg) / height (meter) ^ 2 4) instead of printing the computed 'bmi', you ask user for input a value stored at BMI array current index...
17th Jun 2021, 7:54 PM
visph
visph - avatar