Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* program to convert binary to decimal*/
- #include<stdio.h>
- #include<conio.h>
- #include<math.h>
- void main()
- {
- char ch;
- do {
- int n,digit=0,k=0,rem=0;
- clrscr();
- printf("\nEnter a binary number: ");
- scanf("%d",&n);
- while(n!=0)
- {
- rem=n%10;
- digit=digit+rem*pow(2,k);
- k++;
- n/=10;
- }
- printf("Converted Decimal:%d",digit);
- printf("\nDo you want to continue? (y/n)");
- scanf("%c",&ch);
- }
- while(ch == 'y'|| ch == 'Y');
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment