While was solving thisproblem on hackerrank. I noticed a strange thing in for loop. First, let me show you simple code:
#include <bits/stdc++.h>
using namespace std;
#define modVal 1000000007;
int main() {
for(long long int i=2;i>=0;--i){
cout<<"here: "<<i<<endl;
}
}
input: 123
output: here: 2 here: 1 here: 0 164
Now, when I change long long int
to unsigned long long int
in for loop for the initialization of variable i
. The variable i
gets initialized with 18446744073709551615
. Why is this happening?
Aucun commentaire:
Enregistrer un commentaire