Functions


Why is this wrong?

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

#include <iostream>
using namespace std;

void neg_msg(string a);
string a = "Negative";

void zero_msg (string b);
string b = "Zero";

void pos_msg (string c);
string c = "Positive";
int main()

{
	int a;
	cout << "Enter an integer value for variable a." 
	<<endl;
	cin >> a;
	
	if (a < 0)
	{cout << "The integer you have entered is "<< a
	<< " ." << endl;}

	if ( a == 0 )
	{ cout << " The integer you have have enter is " << b
	<< " ." << endl;}

	if ( a >0 )
	{ cout << " The integer ypu have entered is " << c 
	<< " ." << endl;
	return 0;
}
Declaration

int a;

hides global declaration

string a = "Negative";

in the function block scope.

Also I do not see the closing brace after statement

1
2
3
	if ( a >0 )
	{ cout << " The integer ypu have entered is " << c 
	<< " ." << endl;
Last edited on
Topic archived. No new replies allowed.