HOW TO FIND ONE'S COMPLEMENT USING ~

# include<bits/stdc++.h>
using namespace std;

int main()
{
    int a=-8;
    int c=~a;
    cout<<c<<endl;
    
}
O/P= 7 
why we have put negative sign in 8 to get correct one's complement of 8?
# include<bits/stdc++.h>
using namespace std;

int main()
{
    int a=8;
    int c=~a;
    cout<<c<<endl;
    
}
O/P= -9
how o/p is -9?