void display with while loops

I keep getting an error when I use void display in the header. I need to use it for my assignment. I don't know why it's doing this? (this is also a portion of the code)

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
  #include <iostream>
#include <limits>

void(display);
using namespace std;


int main(void)
{
	char selection = ' ';


	do
	{
		cout << "\tHelp(H)\t Arithemetic(A)\t Relational(R)\t Logical(L)\tQuit(Q)\n";			
		cout << "      Select a letter for the operation that you would like to perform\n";
		cin >> selection;


switch (selection)
{

	case ('h'):
	case ('H'):			//select H or h to select the help menu
 {
	cout << "Each letter that you input will take you to a            different operation.\n"

<< "If you select A, you will be taken to a program that will subtract or divide 2 integers.\n"

<< "If you select R, you will be taken to a program that will rationalize 2 integers.\n"

<< "If you select L, you will be taken to a program that will send you to a logical operation.\n"

<< "If you select Q, you will quit the program.\n";
			system("pause");			

//added in this line to make it where pressing any key returned the user to the regular menu
			break;
		}
//ends the H/h selection menu


		case ('a'):
		case ('A'):


		{
			int a, b;
			char c = ' ';		//declaring variables 


			cout << "Input a value for a = ";		//inputting numbers
			cin >> a;

while (cin.fail())

{		cout << "Invalid Input - please try again. \n";		
			cin.clear();										//this code stops the program from infinite loops 
				cin.ignore(256, '\n');
				cin >> a;
}
			cout << "Input a value for b = "; //inputting numbers
			cin >> b;


			while (cin.fail())
			{
				cout << "Invalid input - please try again. \n";
				cin.clear();
				cin.ignore(256, '\n');
				cin >> b;
			}


                   while (c != '1' || c != '2')				

//makes a loop for when c doesn't equal 1 or 2
			{


	cout << "Input a value of 1 for subtraction or 2 for division ";
		cin >> c;


	if (c == '1')			//== when c is equal to 1
	{

cout << "(a - b) is equal to " << a << " - " << b << " = " << (a - b) << "\n";
					system("pause");	//returns users to the main menu
					break;				//system stop here if it c was inputted as 1
				}


				else if (c == '2')
				{
					cout << "(a / b) is equal to " << a << " / " << b << " = " << (a / b) << "\n";
					system("pause");
					break;
				}
				else
					cout << "Error, enter a proper integer value\n";		//when they input a number that isnt 1 or 2 it tells them to fix it
																		
			}
		
			system("pause");
			break;




		}	return 0;}
Last edited on
Did you mean
void display();

Otherwise, tell us what the error message said.
In addition to what lastchance mentioned,

Line 75: Your if statement is always going to be true. If c is '2', then != '1' will be true. If c is '1', then != '2' is true. What you want is :
 
  while ( ! (c == '1' || c == '2'))	


Line 13: You have a do statement, but I don't see a while clause to go with it.

Line 113: You have unbalanced braces. This would be easier to spot if you used some reasonable indentation.


Last edited on
Topic archived. No new replies allowed.