jeudi 9 avril 2015

how does the below code output 3? (how does the below code read?)

The specific part I do not understand is how the -a in the if statement changes -3 to 3. Can someone explain how the -a changes a = -3 to a = 3?



#include <iostream>

int main(){

signed a = -3;

if (a < 0){ std::cout << -a << std::endl; }
else { std::cout << a << std::endl; }

system("pause");
return 0;
}

Aucun commentaire:

Enregistrer un commentaire