C programming
C programming

Binary To Decimal in C

Binary To Decimal in C

C Programming
C Programming

Binary To Decimal in C

 

Question:

Write a C program to convert a Binary number into Decimal number.

 

Solution:

#include<stdio.h>
#include<math.h>
void Binary_to_Decimal(int);

int main(){
int binNum;
printf(“Enter the Binary Number”);
scanf(“%d”,&binNum);
Binary_to_Decimal(binNum);
return 0;
}

void Binary_to_Decimal(int binNum){
int power=0;
int decNum=0;
while(binNum>0){
int lastDigit= binNum%10;
decNum = decNum + (lastDigit*pow(2,power));
power++;
binNum=binNum/10;
}
printf(“The decimal of given number is %d”,decNum);
}

 

 

Topics Covered :

  • decimal number
  • decimal conversion
  • cp training
  • decimal
  • binary conversion
  • binary number
  • computer training
  • binary
  • c language training
  • arithematic operators
  • mod operator
  • division operator
  • c language trainee
  • cp sessions
  • computer programming
  • while loop
  • c programming
  • loops
  • base 2
  • convert
  • base 10
  • computer
  • number system
  • c language

 

 


 

Thanks for reading this blog. Hope you get satisfied with the blog and definitely this blog must have valued your time and effort of reading.

Take a time to connect our other digital creations such as Instagram , Facebook and Youtube.

 

πŸ§‘β€πŸ’»πŸ§‘β€πŸ’»Β Social MediaΒ LinksΒ ofΒ Tech DCodeΒ :

πŸ‘‰πŸ»Β YouTube :Β https://www.youtube.com/channel/UCjJnEdeugftBwQ3yMuD4B_A
πŸ‘‰πŸ»Β Instagram :Β https://www.instagram.com/thetechdcode/
πŸ‘‰πŸ»Β Facebook Page :Β https://www.facebook.com/thetechdcode
πŸ‘‰πŸ»Β Twitter :Β https://twitter.com/thetechdcode
πŸ‘‰πŸ»Β Telegram Channel :Β https://t.me/thetechdcode
πŸ‘‰πŸ»Β Tech DCode Linktree :Β https://linktr.ee/thetechdcode
πŸ‘‰πŸ»Β My Personal Handles :Β https://linktr.ee/virtualshivamin

πŸ§‘β€πŸ’»πŸ§‘β€πŸ’»Β Social Media LinksΒ ofΒ SHIVAM SINGHΒ (OWNER) :

πŸ‘‰πŸ»Β Instagram :Β https://www.instagram.com/virtualshivamin/
πŸ‘‰πŸ»Β Facebook Page :Β https://www.facebook.com/virtualshivamin/
πŸ‘‰πŸ»Β Twitter :Β https://twitter.com/virtualshivamin/
πŸ‘‰πŸ»Β Personal Linktree :Β https://linktr.ee/virtualshivaminΒ 

Leave a Reply

Your email address will not be published. Required fields are marked *