Skipping functions

So i have to do a school project.. i need to create a program that calculates BMI and does other stuff involving that, i did what i thought it was right but when i run the program it skips all the functions and i couldnt manage to figure it out .. i really need help asap cause i have to deliver it tomorrow morning
thank you and hope you can help me.. btw everything is in portuguese because i'm from portugal

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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
 #include <iostream>
#include <math.h>

//Marina Tchá Tchá Tchá


using namespace std;
void function_menu1 ();
int function_num ();
void function_menu2 ();
int function_A ();
int function_B();
int function_C ();
int function_D ();
int function_cont ();
int main()

{


setlocale(LC_ALL,"Portuguese");
function_menu1 ();
do
{
function_num();
}
while (function_cont());

}
void function_menu1 ()
{
    cout<< "******************************************\n*             Olá utilizador!            *\n*   Este programa serve de calculadora.  *\n*Vai introduzir dois números e de seguida*\n* será apresentado um menu com as opções *\n*         de cálculos possíveis.         *\n******************************************\n";
}

void function_menu2()
{
  cout << endl;
  cout << endl;
  cout << "****************************************************************\n* Escolha uma letra de A a D para escolher o cálculo desejado: *\n* A- IMC atual e apresentação do resultado;                    *\n* B- IMC dos últimos 5 anos e apresentar a média;              *\n* C- Conversão do peso em gramas;                              *\n* D- Peso da pessoa com um acréscimo de 15%.                   *            \n****************************************************************\n";
}
int function_num()
{
setlocale(LC_ALL,"Portuguese");

char opcao;

function_menu2 ();
cin >> opcao;

switch (opcao)
{
case 'A':
case 'a':
int function_A ();
break;

case 'B':
case 'b':
int function_B();
break;

case 'C':
case 'c':
int function_C ();
break;

case 'D':
case 'd':
int function_D ();
break;

default:
cout << "Operação inválida.";
}
return 0;
}
int function_A ()
{
cout << "Escolheu a opção A- IMC atual e apresentação do resultado\n";

double peso, altura, calcimc (double, double), IMC;


cout << "Insira o seu peso em quilogramas. Ex.: 70 \n ";
cin >> peso;

cout << "Insira a sua altura em metros. Ex.: 1.80 \n ";
cin >> altura;

IMC = calcimc (peso, altura);
cout << "O teu IMC é: " << IMC << endl;
cout << "\n[ ";


if (IMC >= 10 && IMC < 18.5)
    cout << "Baixo Peso";

else if (IMC >= 18.5 && IMC < 25)
    cout << "Peso Normal";

else if (IMC >= 25 && IMC < 30)
    cout << "Pré-obesidade";

else if (IMC >= 30 && IMC < 35)
    cout << "Obesidade Grau I";

else if (IMC >= 35 && IMC < 40)
    cout << "Obesidade Grau II";

else if (IMC >= 40 && IMC < 204)
    cout << "Obesidade Grau III";

else
    cout << "Valor Inválido";

cout << " ]" << endl;

}

double calcimc (double peso, double altura){

    return peso/(altura*altura);
}


int function_B()
{
cout << "Escolheu a opção B- IMC dos últimos 5 anos e apresentar a média\n";

double imc[5], sum=0, m=0;
int i;

cout << "Introduza o seu IMC (ex:21) em cada um dos 5 anos: " << endl ;

for (i=0; i<5; i++)
{
cin >> imc[i];
sum=sum+imc[i];
}

cout << "A média do seu IMC é: " << endl ;
cout << m/5;
}

int function_C ()
{
cout << "Escolheu a opção C- Conversão do peso em gramas\n";
double peso, altura, calcimc (double, double), IMC;
int gramas;

gramas=(peso*1000);
cout << "A conversão de peso em KG para Gramas é:" << gramas << endl;
}

int function_D ()
{
cout << "Escolheu a opção D- Peso da pessoa com um acréscimo de 15%.\n";
double peso, altura, calcimc (double, double), IMC;
int gramas;
int peso_acresc;

peso_acresc=peso+(peso*0.15);
cout << "O peso que pretende com um acréscimo de 15% é:" << peso_acresc << endl;


}


int function_cont()
{
char executar;
cout << "Deseja continuar a executar o programa? 'S' se sim, 'N' se não.\n";
cin >> executar;
if (executar=='s' || executar=='S')
{
function_num();
}
else if (executar=='n'||executar=='N')
{
cout << "Obrigado pela sua visita, volte sempre!";
return 0;
}
else
{
cout << "Opção inválida.\n";
function_cont();
}
return 0;
}

Lines 54, 59, ,64, 69: These lines simply declare the functions. They don't call them. Remove "int " from each line and you should get further. I'll keep looking at the code but I wanted to give you this bit right away.
Function_C and function_D both define local variable peso and use it without setting it. What should peso contain? Ah. I see it's the user's weight. You could make it a global, or, if the professor marks off for that, then return the weight from function_A() and pass it into function_C and function_D

Some other functions have variables that aren't used. If you have time you should remove them.

Functions A, B, C, and D don't return anything. Ideally you'd fix these by definig them as void and fixing the declarations at the top of the program, but with the time constraint, you might want to just add return 0; at the end of each one.

function_cont() isn't quite right. It should just return 0 or 1 to indicate whether the user wants to continue. Put in a loop if the user enters an invalid choice:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
int
function_cont()
{
    char executar;
    while (true) {
        cout << "Deseja continuar a executar o programa? 'S' se sim, 'N' se não.\n";
        cin >> executar;
        if (executar == 's' || executar == 'S') {
            return 1;
        } else if (executar == 'n' || executar == 'N') {
            cout << "Obrigado pela sua visita, volte sempre!";
            return 0;
        } else {
            cout << "Opção inválida.\n";
        }
    }
    return 0;
}

Topic archived. No new replies allowed.