10 Mar 2013

Binary to Decimal Conversion

/*

program to convert binary no. to decimal no.....
 
*/

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
unsigned long int a,b,c=0,s=0,n;
clrscr();
cout<<"Enter your binary number:";
cin>>a;
while (a>0)
{b=a%10;
n=b*pow(2,c);
c+=1;
a=a/10;
s+=n;
}
cout<<"The corresponding decimal no. is="<<s;
getch();
}

Categories: , ,

Related Posts:

  • Chef Teams_solved /* CODECHEF PROBLEM CODE : CTEAMS */  #include <stdio.h> #include <math.h> #define tausch(a,b) b=a+b, a=b-a, b=b-a int X[100100][5]; void f3(int i) { int l=2*i, r=2*i+1, z=i; z=(l<=X[2][4… Read More
  • Random decreasing function_SOLVED /* CODECHEF PROBLEM CODE : RDF */ #include <stdio.h> inline int getn()  {   int n=0, c=getchar_unlocked();   while(c < '0' || c > '9')        c = getchar_unlocke… Read More
  • Money Transformation_solved /* CODECHEF PROBLEM CODE : MONTRANS */ #include<stdio.h>   int T,a,b,c; void solve() { int step=0,cnt=0; int m=a*100+b; while((a>0||b>=c)&&cnt<10000){ cnt++; … Read More
  • Multiply Matrix /* program to multiply two matrices... */ #include<iostream.h>#include<conio.h>  void main(){  clrscr();int x[50][50],y[50][50],z[50][50],i,j,k,a,b,c,d,e,f,g,h;  cout<<"Enter the rows an… Read More
  • Jurassic Park_solved /* CODECHEF Problem code: NI01 */ #include<stdio.h> #include<stdlib.h> int n[100002]; int main() { int t,p,r,k,i,m,q,l,c; scanf("%d",&t); while(t--)  { scanf("%d%d%d%d%d%d",&… Read More

0 comments:

Post a Comment

Copyright © 2025 UPgradeCODING | Powered by Blogger