What am I doing wrong???

I need to write a program that will give me multiple calculation results.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
using namespace std;

int main () {

int x = 8;
int y = 7;

 while (x>0 && y>0)
    { x--;
      y--;
    cout << "x is " << x << endl;
    cout << "y is " << y << endl; }
    
 int calculation = x + y;
 cout << "result is " << calculation << endl;

}


It only calculates the last two numbers: 1 and 0, so therefor it gives me 1.
But i need to calculate x and y each time they are smaller(incremented) by one digit.
Please note that the int calculation formula needs to stay.
Last edited on
The curly brace closing your while loop is in the wrong place, you need to move it from line 13 to line 17.
Thanks man, I've made tons of mistakes in my previous project because I haven't paid enough attention to the curly braces and because of some other stuff, the overall logic for formulas was present, but not the knowledge to implement them.
Topic archived. No new replies allowed.