Guys helps, am creating the program of c++ to calculate BinaryNumber and vise versa using switch case but i end up with so much error
Iam using the following codes
#include<iostream>
usingnamespace std;
int main ()
{
int input;
cout << “1. Binary to Decimal Conversion\n”;
cout << “2. Decimal to Binary Conversion\n”;
cin >> input;
switch (input)
{
case 1:
{
int num,res, i=1, dec=0;
cout << “Enter a Bianry Number: “;
cin >> num;
while (num!=0)
{
dec=dec+(num%10)*i;
i=i*2;
res=num%10;
num=num/10;
}
if(res%10=0 || res%10=1)
cout << “The Decimal Equivalent of the Binary Number is “;
cout << dec;
else
cout << “Not a Binary! Try another numbers between 0’s and 1’s only!”;
break;
}
case 2:
{
int num, i=1, bin=0;
cout << “Enter a Decimal Number: “;
cin >> num;
while (num!=0)
{
bin=bin+(num%2)*i;
i=i*10;
num=num/2;
}
cout << “The Binary Equivalent of the Decimal Number is “;
cout << bin;
break;
}
default:
cout << “That is Invalid!\n”;
break;
}
return 0;
}