Simple C Program with Algorithm, Flowchart, Output - Computer Programming - C
Write a program in C
to convert the decimal number into binary number.
To
write a program in C to print equivalent binary number for the decimal number.
Step-1 :
Start
Step-2 :
Initialize the values for flag = 0, k = 0
Step-3 :
Read the decimal number into n.
Step-4 :
Initialize the values for s = n, rbi = 0
Step-5 :
Check whether the value of S is greater than zero.
Step-6 :
If step‒5 is True do step‒7 to step‒12
Step‒7:
Computer = s%2
Step-8 :
Check the value of 'r' is equal to zero and the value of flag is equal to zero.
Step-9 : If
step‒8 is True, increment k by 1
Step‒10:
If step‒8 is False, assign flag = 1
Step‒11:
Compute rbi = rbi*10*r
Step‒12:
Compute s = s/2
Step‒13:
If step‒5 is False do the following steps
Step‒14:
Initialize s = rbi, bi = 0
Step‒15:
Check whether the value of s is greater than zero or not.
Step‒16:
If step‒14 is True do step‒17 to step‒25
Step‒17:
Compute r = s%10, bi = bi*10*r, Compute s = s/10
Step‒18:
Check s is equal to zero
Step‒19:
If step‒20 is True do the following steps
Step‒20:
Repeat for i = 1 to k
Step‒21:
Compute bi = bi*10
Step‒22:
Increment i by 1
Step‒23:
Print the value of bi
Step‒24:
Stop

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,s,r,i,bi,rbi,flag=0,k=0;
printf("Enter the decimal number :");
scanf("%d",&n);
s=n;rbi=0;
while(s>0)
{
r=s % 2;
if (r==0
&& flag == 0)
k++;
else
flag=1;
rbi=rbi*10+r;
s=s/2;
}
s=rbi;
bi=0;
while(s>0)
{
r=s%10;
bi‒bi*10+r;
s=s/10;
if(s==0)
for(i=1;i<=k;i++)
bi‒bi*10;
}
printf("The binary number is: %d\n",bi);
Enter the decimal
number: 14
The binary number is:
1110
Computer Programming C Laboratory: Practical C Programs : Tag: C Programming : C Program with Algorithm, Flowchart, Output - Write a program in C to convert the decimal number into binary number
Computer Programming C
CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Computer Programming C Laboratory
CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
English Essentials I
EN25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
தமிழர் மரபு - Heritage of Tamils
UC25H01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Calculus
MA25C01 Maths 1 M1 - 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Physics I
PH25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Chemistry I
CY25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Makerspace
ME25C04 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Computer Programming C
CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Computer Programming Python
CS25C02 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Fundamentals of Electrical and Electronics Engineering
EE25C03 1st Semester EEE Depart | 2025 Regulation | 1st Semester 2025 Regulation
Introduction to Mechanical Engineering
ME25C03 1st Semester Mechanical Dept | 2025 Regulation | 1st Semester 2025 Regulation
Introduction to Civil Engineering
CE25C01 1st Semester Civil, Agri Departments | 2025 Regulation | 1st Semester 2025 Regulation
Essentials of Computing
CS25C03 1st Semester - AIDS, CSE, CSE(CY), IT Department | 2025 Regulation | 1st Semester 2025 Regulation
Applied Physics I Laboratory
PH25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Applied Chemistry I Laboratory
CY25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Computer Programming C Laboratory
CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Computer Programming Python Laboratory
CS25C02 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Engineering Drawing
ME25C01 EEE, Mech, Agri, EEE Depts | 2025 Regulation | 2nd Semester 2025 Regulation
Basic Electronics and Electrical Engineering
EE25C04 1st Semester ECE Dept | 2025 Regulation | 1st Semester 2025 Regulation
Essentials of Computing - Laboratory
CS25C03 1st Semester AIDS, CSE, CSE(CY), IT Depts | practical Laboratory Manual | 2025 Regulation | 1st Semester 2025 Regulation