How to connect void statements ( Hope I asked this question right)

So right now my main concern is trying to have my void statements carry on throughout the menu. As of right now when I hit to view my dafaq statement and nothing comes up on that menu. I hope I am asking that question right but how do I view my dafaq statement when I hit 1.

Any help would be greatly appreciated as I have been trying to figure this out for 2 hours.

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
#include <iostream>
#include <cstdlib>
using namespace std;
float stored_values(10);
int x=0;
void display_menu (), add_values (), edit_value(), print_values(), display_stats(),exit_program();
int main ()
{
cout<<" Please choose from any of the following options "<<endl;
display_menu();
while (x !=0);
return 0;
}

void display_menu()
{
cout << " please choose an option"<<endl;
cout << "1 - add values"<<endl;
cout << "2 - edit values"<<endl;
cout << "3 - print values"<<endl;
cout << "4 - display stats"<<endl;
cout << "5 - exit program"<<endl;
cin>>x;
while (x<5)
{
    if(x=1){void add_values(float stored_values[10]);}
    if(x=2){void edit_value();}
    if(x=3){void print_values();}
    if(x=4){void display_stats();}
    if(x=5){void exit_program();}
}
}

void add_values(float stored_values[10])
{
    cout<< "DAFAQ"<<endl;
}
= sets x == compares
while (x<5) .... What if x==5?
Last edited on
I don't know who is teaching you C++, but he is doing a terrible job so far.

1) Avoid using global variables, especially while you are a beginner
2) float stored_values(10); means the same as: float stored_values=10;
but you probably wanted to use something like vector<float> stored_values(10);
3) while (x !=0); this is probably a bug, it will hang whenever x!=0
4) if(x=1){void add_values(float stored_values[10]);} to make a function call, you dont list types, just parameters, so:
if(x=1){add_values(stored_values);}
5) if(x=1) should be if(x==1)

With all those bugs and problems in the code, any question you have is irrelevant. It is a miracle that the program is working at all.
Last edited on
@Kevin... That was a little harsh... true, but harsh. :)

@Aflon I removed your float variable, this works. Now, go from here.


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
#include <iostream>
#include <cstdlib>
using namespace std;

void display_menu ();
void add_values (),edit_values(),print_values(),display_stats(),exit_program();

int main ()
{
    cout<<" Please choose from any of the following options "<<endl;
    display_menu();
}

void display_menu()
{
    // float stored_values[10];
    int x=10;
    cout << " please choose an option"<<endl;
    cout << "1 - add values"<<endl;
    cout << "2 - edit values"<<endl;
    cout << "3 - print values"<<endl;
    cout << "4 - display stats"<<endl;
    cout << "5 - exit program"<<endl;
    cin>>x;
    cout << x << endl;
    if (x==1) {add_values();}
    if (x==2) {edit_values();}
    if (x==3) {print_values();}
    if (x==4) {display_stats();}
    if (x==5) {exit_program();}
}

void add_values()
{
    cout<< "adding values" <<endl;
}
void edit_values()
{
    cout<< "editing values" <<endl;
}
void print_values()
{
    cout << "printing values" << endl;
}
void display_stats(){
cout << "Displaying stats" << endl;
}
void exit_program(){
cout << "Exiting program." << endl;
}
Thank you guys for the help I am trying my best to grasp this stuff but it has been difficult doing it by myself especially the rate at which we are learning. I have learned about functions/arrays in around a week
Topic archived. No new replies allowed.