how to call my function

i am writing my code with ask for weight and height once enter the W and H I have to call my void calculateBMI function to calculate BMI, When enter my code like that it shows the error variable or filed "calculateBMI" declared void what is that mean?

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <iostream>
#include <string>
#include <fstream>

#include <stdio.h>
#include <iostream>
float a,b;
float BMI;

int AddBiometric();
void calculatBMI(float x, float y, float &BMI);


void caluclateBMI(float x, float y, float &BMI)
{
    BMI = (a / (float(b) *float (b)));
}

int main()
{  char c;
   FILE *file;

   std::cout<<"To Add Weight: Type W\n";
   std::cout<<"To Add Height: Type H\n";
   std::cout<<"Selection>";
   std::cin>>c;





if (c == 'w')


{


    std::cout<<"Enter the Weight in pounds:\n";
    std::cin>>a;
    std::cout<<"Biometric Added\n";
    file= fopen("health_record.dat","a");
    fprintf(file,"W ");
    fprintf(file,"%f\n",a);
}




else if(c == 'h')
{





    std::cout<<"Enter the Hight in feet:\n";
    std::cin>>b;
    std::cout<<"Biometric Added\n";
    file= fopen("health_record.dat","a");
    fprintf(file,"H ");
    fprintf(file,"%f\n",b);
}
void calculatBMI(a,b,&BMI);
fclose(file);









}
You don't need the void in front of your function call. And you don't need the ampersand in front of BMI.

Where have you implemented your calculatBMI() function?


Also you should be using C++ streams instead of the C FILE* and you should get rid of all those global variables.

this is only a part of my code all the functions are requirement of my project! I can not change it
jlb, calculateBMI is defined at line 14.

qingcheng, change line 63 to calcualteBMI(a,b,BMI); This is the way you call a function. You only have to give the type when you declare or define it, like on lines 11 & 14. Speaking of which, you don't need line 11 since you define the function right after that.


jlb, calculateBMI is defined at line 14.

But I didn't ask about calculateBMI(), I asked about calculatBMI() note the difference.
Oh! Good catch! Sorry about that.
Topic archived. No new replies allowed.