0

I am confused why else condition is executed in below code.

#include <iostream>
using namespace std;

int main() {
    unsigned a = 0;
    int b = 2;
    if (a + b >= -2) 
        cout << a + b << ">=" << -2 << endl;
    else
        cout << a + b << "<" << -2 << endl;
    return 0;
}

if we do cout<<a+b, output is 2 then why else condition is executed here? what is role of unsigned keyword here?

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Sushil
  • 1

0 Answers0