PROGRAM
//Program to display ones complement of a given positive binary number
#include <iostream>
using namespace std;
int main()
{
int len,i;
string bin,ones;
cout<<"ENTER BINARY NUMBER: ";
cin>>bin;
len=bin.length();
ones.resize(len);
for(i=0;i<len;i++)
{
if(bin[i]=='0')
{
ones[i]='1';
}
else
{
ones[i]='0';
}
}
cout<<"\nONE'S COMPLEMENT: "<<ones;
return 0;
}
OUTPUT
//Program to display ones complement of a given positive binary number
#include <iostream>
using namespace std;
int main()
{
int len,i;
string bin,ones;
cout<<"ENTER BINARY NUMBER: ";
cin>>bin;
len=bin.length();
ones.resize(len);
for(i=0;i<len;i++)
{
if(bin[i]=='0')
{
ones[i]='1';
}
else
{
ones[i]='0';
}
}
cout<<"\nONE'S COMPLEMENT: "<<ones;
return 0;
}
OUTPUT
1 comments :
commentsSir/mam can we talk with each other because i want help for my blog
Reply