Undeclared (First Use This Function)?

I'm trying to write a program that asks for the x and y coordinates of a point, then outputs which quadrant that point would be located under. However, my variable int qrant is not working in my functions. I receive the error message "'qrant' undeclared (first use this function)" in the main part of my program. Any help - even not related to this exact problem - would be appreciated. Thanks.

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

void inp(int& x_cord, int& y_cord);//sets 'x_cord' and 'y_cord' equal to user's input
void calc(int& x_cord, int& y_cord, int& qrant);//checks the values of the x and y coordinates and finds the corresponding quadrant
void outp(int& x_cord, int& y_cord, int& qrant);//outputs results in terms of quadrant or axis intercept

int main()
{
    char cont = 'y';
    int x_cord, y_cord;
    
    do//do-while loop allows program to be run multiple times
    {inp(x_cord, y_cord);
    calc(x_cord, y_cord, qrant);
    outp(x_cord, y_cord, qrant);
    cin >> cont;}
    while(cont == 'y' || cont == 'Y');
    
    return 0;}
    
void inp(int& x_cord, int& y_cord)//***INPUT***
{
    cout << "Please enter the x and y coordinates of a point on a graph, and I will tell you what quadrant that point is in.\n"//prompt
         << "Enter the x coord (whole number): ";
    //Take 'x_cord'
    cin >> x_cord;
    cout << "Enter the y coord (whole number): ";
    //Take 'y_cord'
    cin >> y_cord;
    cout << endl << "The point you have given me is (" << x_cord << ", " << y_cord << ")\n\n";}

void calc(int& x_cord, int& y_cord, int& qrant)//***CALCULATIONS***
{
    if(x_cord > 0 && y_cord > 0)//I
    qrant = 1;
    if(x_cord < 0 && y_cord > 0)//II
    qrant = 2;
    if(x_cord < 0 && y_cord < 0)//III
    qrant = 3;
    if(x_cord > 0 && y_cord < 0)//VI
    qrant = 4;}
    
void outp(int& x_cord, int& y_cord, int& qrant)//***OUTPUT***
{
    //Y-AXIS
    if(x_cord == 0)
    cout << "Your point lies on the y-axis.";
    else
    {cout << "Your point is in Quadrant ";
    if(qrant == 1)
    cout << "I";
    if(qrant == 2)
    cout << "II";
    if(qrant == 3)
    cout << "III";
    if(qrant == 4)
    cout << "VI";}  
    //X-AXIS
    if(y_cord == 0)
    cout << "Your point lies on the x-axis.";
    //ORIGIN
    if(x_cord == 0 && y_cord == 0)
    cout << "Your point lies on the origin.";
    
    cout << endl << endl << endl <<  "Do you want to continue? < 'y' or 'n' >: ";}
You never declared qrant in main().
Thanks. I had never seen the error message so I was really confused!
Topic archived. No new replies allowed.