Explore the new and unique programing techniques with just a click and u can visit DEVGROUP , COMPUTERS & TECHNOLOGY,HACKING PROTECT,ARTIFICIAL INTELLIGENCEand FACEBOOK PAGE
Tuesday, 22 January 2013
to convert binary number to decimal equivalent c++
int main()
{ int n,i,sum,rem;
sum=0,i=0;
cout<<"enter the binary number ";
cin>>n;
while(n!=0)
{ if((n%10==0) || (n%10==1))
{rem=n%10;
sum=sum+(rem*pow(2,i));
n=n/10;
++i;
}
else {cout<<"entered number is not binary";goto a;}
}
cout<<"the decimal number is:"<<sum;
a:
getch();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment