Compliment of a decimal number

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int num,n=1,m,cmp;
cout<<"Enter a decimal number : ";
cin>>num;
m=7;
while(num<=m||num>m)
{   int value=1;
if(num<=m)
{
cmp=m-num;
cout<<"Compilment is : "<<cmp;
return 0;
}
n=n+1;
for(int i=0;i<n;i++)
value=value*2;
m=value-1;
}
getch();
}

       Decimal Number = 61
Binary Number of 61 = 111101
            Compliment    = 000010   =  2

Popular posts from this blog

Shutdown Pc

Ellipse using OpenGl

String Comparisons