24/09/2022 satyams.friend 0 Comments Method to calculate Decimal to Binary Number Take a decimal input from the user for example : if user enter a decimal 12 We keep on dividing the number 12 by 2. 12 / 2 = 6, reminder 0 06 / 2 = 3, reminder 0 03 / 2 = 1, reminder 1. 01/ 2 = 1, reminder 1. Decimal to binary So Binary equivalent of 12 is 1100. Write all reminders bottom to top. It’s binary equivalent of decimal (12)10=(1100)02 Source Code : #include<stdio.h> #include<conio.h> void main() { clrscr(); int t, n, r=0, p=1, bin=0; printf("Enter a number\n"); scanf("%d",&n); t=n; while(n>0) { r=n%2; n=n/2; bin=bin+(r*p); p=p*10; } printf("Binary of decimal %d = %d",t,bin); getch(); } YouTube Video : https://youtu.be/2SSRRtaKH0I Leave a Reply Cancel replyYour email address will not be published. Required fields are marked *Comment * Name * Email * Website Save my name, email, and website in this browser for the next time I comment. Post navigation Previous: Next: