Function-Calculating BMI by using Function

Mar 8, 2020 at 9:45am
int main(){
int a=0,b=0;
float c=0;
cin >> a;
cin >> b;
BMI(&a,&b,&c);
cout << c;
return 0;
}

void BMI(=,,=) {
// Please fill this blank???
return ???;
}

please help me, I've tried so many times, but it didn't work out.
Mar 8, 2020 at 9:50am
We can't see what you did write, so we cannot explain what you did wrong.

For starters, read tutorial about functions: http://www.cplusplus.com/doc/tutorial/functions/
Mar 9, 2020 at 12:27pm
1
2
3
4
void BMI(=,,=) {
// Please fill this blank???
return ???;
}


Filling in the blank won't give you a program that compiles.

First of all, the argument list for the function needs to be populated. It looks like you are trying to call the function with pointers to 2 ints and 1 float. So you need to fill in the correct arguments and types inside the parentheses.

Also, you are not #including any headers. You need at least <iostream>. And cin and cout are in the std:: namespace, so you should be using std::cin/std::cout (preferably) or "using namespace std;".

Also, the call to BMI does not know what BMI() looks like, so you need to either define BMI before main(), or have a forward declaration of the function.

I have no idea how to calculate BMI, so I cannot help you fill in the blank.

Your function is declared as "void", meaning it does not return anything. Therefor, there is no need for a return statement, and if you have one, it certainly will not return a value.
Last edited on Mar 9, 2020 at 12:27pm
Topic archived. No new replies allowed.