binary_to_deci
binary_to_deci
// binary to deci.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream"
using namespace std;
int main()
{
int n=0,rem=0,deci=0,i=1;
cout <<"Enter the binarry number:";
cin>>n;
while (n!=0)
{
rem = n%10;
n=n/10;
deci =deci+ rem*i;
i*=2;
}
cout<<"deci="<<deci;
return 0;
}
// binary to deci.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream"
using namespace std;
int main()
{
int n=0,rem=0,deci=0,i=1;
cout <<"Enter the binarry number:";
cin>>n;
while (n!=0)
{
rem = n%10;
n=n/10;
deci =deci+ rem*i;
i*=2;
}
cout<<"deci="<<deci;
return 0;
}
No comments: