My BMI calculator wont work but I do not see whats wrong

I used the formula from this site: http://www.epic4health.com/bmiformula.html
My code thus far is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "stdafx.h"
#include <iostream>

int division(int x, int y)
{
	return (x/y);
}
int main()
{
	using namespace std;
   
   cout << "What is your height in inches? " << endl; 
   int x;
   cin >> x;
   int a;
   a = x * x;
   cout << "What is your weight in pounds?" << endl;
   int y;
   cin >> y;
   cout << y << endl;
   int b;
   b = division(y,a);
   cout << b << endl;
   int c;
   c = b * 703;
   cout << "Your BMI is: " << c << endl;

   return (0);
}

I have narrowed it down to the division operator that will not work. Can anyone help me with this.
Help me guys. I do not understand why the division operator is not working.
1
2
3
4
double division(double x, double y)
{
	return (x/y);
}

1
2
3
4
5
//...
double b;
b = division(y,a);
cout << b << endl;
//... 

Last edited on
As m4ster r0shi implied, you should be using doubles.

Though, here's an extra question: why do you have a function there? You seriously don't need it... do you?

-Albatross
I dont need it but i just put it there as a way to try and solve my problem but I dont know about doubles yet. Do you guys mind just giving me a brief explanation of doubles.
double is a (fundamental) data type. It is used to hold numbers with decimal digits.
Find more here: http://cplusplus.com/doc/tutorial/variables/
Last edited on
Topic archived. No new replies allowed.