Untitled
unknown
plain_text
a year ago
497 B
4
Indexable
#include<iostream> using namespace std; void binary(int){ int i,k; for(i=3;i>=0;i--){ k=(a>>i)&1; cout<<k<<endl; } } int main(){ int n; cout<<"enter a number"<<endl; cin>>n; cout<<"the hex equ is:"<<"%x"<<endl; cout<<"the oct equ is:"<<"%o"<<endl; cout<<"the binary equvalent:"<<binary(n)<<endl; cout<<"the 1s complement:"<<binary(-n-1)<<endl; cout<<"the 2s complement:"<<binary(-n)<<endl; return 0; }
Editor is loading...
Leave a Comment