2 errors, 1 warning

Dont really know whats happening with my code 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
#include <iostream>
using namespace std;

int main()
{
    int num1;
    int num2;
    int temp;
    bool found;
  
    cout << "Enter two integers";
    cin >> num1 >> num2;
    cout << endl;
  
    if (num1 >= num2) && num2 > 0 /* 15:26: error */
        switch (num1 % num2)      /* 16:9: error  */
        {
            case 1:
                found = (num1 / num2) >= 6;
                break;
            case 2:
            case 3:
                num1 = num2 / 2;
                break;
            default:
                num2 = num1 * num2;
        }
    else                          /* 27:9: warning */
    {
        found = (2 * num2 < num1);
        if(found)
            cin >> num2;
            num1 = num2 - num1;
            temp = (num1 + num2) / 10;
        
            if (num2)
            {
                num1 = num2;
                num2 = temp;
            }
    cout << num1 << " " << num2 << endl;

    }
return 0;
}


right now its saying it has these three problems:
16:9: error: expected ';' before 'switch'
27:9: warning: statement has no effect [-Wunused-value]
15:26: error: label 'num2' used but not defined

I dont think i can put a ";" before switch since that get in the way of the else function. I dont understand the warning since that line is for the closing bracket. I have no idea why num2 is not defined. please help.

Last edited on
Line 15 should be:
if (num1 >= num2 && num2 > 0)
You also need an opening bracket just before the switch statement.

I would recommend studying a basic C++ book as you seem to have trouble with the syntax.

Good luck!
Topic archived. No new replies allowed.