void binary()
{cout<<"Please enter 0's and 1's and maximum of 8 places, no decimal or negative numbers"<<endl;
cin.get(num,8);
cin.ignore(80,'
');
for(a=0;a<8;a++)
{
bnum[a]=atoi(num);
}
if(((bnum[0]*128)+(bnum[1]*64)+(bnum[2]*32)+(bnum[3]*16)+(bnum[4]*8)+(bnum[5]*4)+(bnum[6]*2)+(bnum[7]*1))>256)
{
cout<<" Sorry sir/ma'me, you've entered an invalid number please try again"<<endl;
binary();
}
else
{
bin=((bnum[0]*128)+(bnum[1]*64)+(bnum[2]*32)+(bnum[3]*16)+(bnum[4]*8)+(bnum[5]*4)+(bnum[6]*2)+(bnum[7]*1));
cout<<bin<<endl;
title();
}
}
(Edited by miaka284 at 9:40 am on Nov. 29, 2001)

New Topic/Question
Reply




MultiQuote




|