i can't compile the program. is there anything wrong with my function parameter? is it because of my array declaration(char category[SIZE][15])? I've made it as 2D array since column part holds the size of the alphabet. could you guys point out what is wrong with my code and how to pass the array as the function parameter? i'm sorry i'm completely new on this topic.
#include<iostream>
#include<string.h>
using namespace std;
const int COLSIZE=3;
const int NAMESIZE=30;
void inputPersonalData(int, long[],int,char[],float[],float[]);
void calcBMI(int,float[],float[],float[]);
void bmiCategory(int,float[],char[]);
void displayPersonalData(int,long[],char[],float[],float[],float[],char[]);
void inputCal(int,char[],long[],float[][COLSIZE],char[]);
int main()
{
int SIZE;
long ID[SIZE];
char name[NAMESIZE];
float weight[SIZE];
float height[SIZE];
float BMI[SIZE];
char category[SIZE][15];
char meal[COLSIZE][10];
float calIntake[SIZE][COLSIZE];
cout<<"Enter the number of models: ";
cin>>SIZE;
inputPersonalData(SIZE,ID,NAMESIZE,name,weight,height);
calcBMI(SIZE,weight,height,BMI);
bmiCategory(SIZE,BMI,category);
displayPersonalData(SIZE,ID,name,weight,height,BMI,category);
strcpy(meal[0],"BREAKFAST");
strcpy(meal[1],"LUNCH");
strcpy(meal[2],"DINNER");
inputCal(SIZE,name,ID,calIntake,meal);
return 0;
}
void inputPersonalData(int rowSize, long id[],int nameSize, char nama[],float berat[],float tinggi[])
{
for(int i=0;i<rowSize;i++)
{
cout<<"\nModel "<<i+1<<"'s information\n\n";
cout<<"ID: ";
cin>>id[i];
cout<<"Name: ";
cin>>ws;
cin.getline(nama,nameSize);
cout<<"Weight in kg: ";
cin>>berat[i];
cout<<"Height in m: ";
cin>>tinggi[i];
cout<<endl<<"***************************************"<<endl;
}
}
void calcBMI(int rowSize,float berat[],float tinggi[],float bmi[])
{
for(int j=0;j<rowSize;j++)
{
bmi[j]=(berat[j]/tinggi[j])/tinggi[j];
}
}
void bmiCategory(int rowSize,float bmi[],char category[])
{
for(int k=0;k<rowSize;k++)
{
if(bmi[k]>25)
strcpy(category[k],"OVERWEIGHT");
else if(bmi[k]>18)
strcpy(category[k],"NORMAL");
else
strcpy(category[k],"UNDERWEIGHT");
}
}
void inputCal(int rowSize,char nama[],long id[],float calorie[][COLSIZE],char mealName[])
{
for(int row=0;row<rowSize;row++)
{
cout<<"Model "<<row+1<<" ("<<nama[row]<<", ID: )"<<id[row]<<" DAILY CALORIE INTAKE:\n";
for(int col=0;col<COLSIZE;col++)
{
cout<<"Calorie intake for "<<mealName[col]<<": ";
calorie[row][col];
}
}
}
void displayPersonalData(int rowSize,long id[],char nama[],float berat[],float tinggi[],float bmi[],char category[])
{
cout<<"No.\tID\tName\t\t\tWeight(kg)\tHeight(m)\tBMI\tCategory\n";
for(int m=0;m<rowSize;m++)
{
cout<<m+1<<"\t"<<id[m]<<"\t"<<nama[m]<<"\t"<<berat[m]<<"\t"<<tinggi[m]<<"\t"<<bmi[m]<<"\t"<<category[m]<<endl;
}
}