google search

Popular Posts


Welcome to BCA Notes

>>>>>>>>>>>>>>>>

Visitors

Search This Blog

Blogger templates

Visitor Map


Thursday 26 June 2014

c++ Basic projects Converting a binary number to decimal

Source Code:-

#include<iostream.h>
#include<conio.h>
#include<math.h>
int main()
{
  int x[10],count=0,n,sum=0,j,k=0;
  cout<<"Enter Binary Number: ";
  cin>>n;
 
  while(n>0)
  {
  x[count]=n%10;
  n=n/10;
  count++;
  }
  for(j=0;j<count;j++)
  {
      sum=sum+x[j]*pow(2,k);
      k++;
  }
  cout<<"Decimal Number: "<<sum;
  getch();
  return 0;
  }

For any questions query:-
Contact Me

0 comments:

Post a Comment