Lab 9

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

#include <iostream>

using namespace std;


#define SIZE 1
void readData (double w[], double h[]);
double calBMI( double w, double h );
void display (double bmi[]);

int main ()
{
double studWeight[SIZE];
double studHeight[SIZE];
double studBMI[SIZE];
int i;

readData (studWeight, studHeight);

for (i=0; i<SIZE; i++)


studBMI[i] = calBMI(studWeight[i],studHeight[i]);
display (studBMI);

system ("pause");
return 0;
}

void readData (double w[], double h[])


{
int i;
for (i=0; i<SIZE; i++)
{
cout << "Student " << i+1
<< "\nweight: ";
cin >> w[i];
cout << "Height: ";
cin >> h[i];
}
}

double calBMI( double w, double h )


{
return w/(h*h);
}

void display (double bmi[])


{
int i;
for (i=0; i<SIZE; i++)
cout << "student " << i+1 << " BMI: "
<<bmi[i] <<endl;
}

You might also like