Please help with C++ Program?

I need to know whats wrong with my code.

This is the instruction. I must do it this way or i will get a zero tomorrow.

You will create a program that calculates and outputs the BMI for two people.

variables(in the main)
int height1, height2, wieght1, weight2;
double bmi1, bmi2;
double scalar = 703.0;

Functions:
Calculates and returns the bmi based on height h, weight w and scalar s
*HINT* We cannont use ^ to raise things to a power, so think about what squaring means
double getBMI(int h, int w, double s)

Informs the user of a single bmi, b. This function should make use of the <iomanip> features to display the bmi to decimal places.
void output (double b)

all input will be done in main

Here is my code so far

#include <iostream>
#include <iomanip>
using namespace std;
double getBMI (int h, int w, double s)


return (w/h*h)^a;


void output (double b){
cout<<"your bmi is:"<<b;
}

int main(){
int height1, height2, weight1, weight2;
double bim1, bim2;
double scalar = 703.0;
cout<<"Person 1 height:"<<endl;
cin>>height1;
cout<<"Person 2 height:"<<endl;
cin>>height2;
cout<<"Person 1 weight:"<<endl;
cin>>weight1;
cout<<"Person 2 weight:"<<endl;
cin>>weight2;
BMI1= getBMI(height1, weight1, scalar)
BMI2= getBMI(height2, weight2, scalar)
output(BMI1);
output(BMI2);

}

return 0;

C:\Users\KILL\Downloads\bmi.cpp||In function 'double getBMI(int, int, double)':|
C:\Users\KILL\Downloads\bmi.cpp|7|error: expected identifier before '(' token|
C:\Users\KILL\Downloads\bmi.cpp|7|error: named return values are no longer supported|
C:\Users\KILL\Downloads\bmi.cpp|11|error: 'b' was not declared in this scope|
C:\Users\KILL\Downloads\bmi.cpp||In function 'int main()':|
C:\Users\KILL\Downloads\bmi.cpp|26|error: 'BMI1' was not declared in this scope|
C:\Users\KILL\Downloads\bmi.cpp|27|error: expected ';' before 'BMI2'|
C:\Users\KILL\Downloads\bmi.cpp|29|error: 'BMI2' was not declared in this scope|
C:\Users\KILL\Downloads\bmi.cpp|29|error: 'output' was not declared in this scope|
C:\Users\KILL\Downloads\bmi.cpp|33|error: expected unqualified-id before 'return'|
||=== Build finished: 8 errors, 0 warnings ===|
Last edited on
Your teacher wrote:
*HINT* We cannont use ^ to raise things to a power


Look at the return statement in getBMI()... What are you doing there? Hint, its something you were specifically told not to do. Also, you will need parenthesis around the h*h in the return statement, to get the proper order of operations.
From the description of your assignment

We cannont use ^ to raise things to a power, so think about what squaring means

From your code

return (w/h*h)^a;


A function body shall start with open brace and end with close brace. So this function definition

double getBMI (int h, int w, double s)


return (w/h*h)^a;

is invalid..
C:\Users\KILL\Downloads\bmi.cpp|4|error: expected unqualified-id before '{' token|
||=== Build finished: 1 errors, 0 warnings ===|

now it says this
u forgot a semicolon
Topic archived. No new replies allowed.