Computer Programming C Laboratory: Practical C Programs

Write a C program to find the equivalent decimal value for the given binary number

C Program with Algorithm, Flowchart, Output

Simple C Program with Algorithm, Flowchart, Output - Computer Programming - C

Write a C program to find the equivalent decimal value for the given binary number.


AIM

To write a program to convent binary to decimal.


ALGORITHM

Step‒1: Start

Step-2 : Initialize decimal = 0, base = 0

Step-3 : Read binary value bnum

Step-4 : Assign bin = bnum

Step-5 : Check the value of bnum is not equal to zero or not

Step-6 : If step‒5 is True, do step‒7 to step‒10

Step-7 : Compute digit = bnum%10

Step-8 : Compute decimal decimal + (digit << base)

Step-9 : Increment base by 1

Step-10 : Compute bnum = bnum/10

Step‒11 : If step‒5 is False, print decimal.

Step‒12 : Stop


FLOWCHART



PROGRAM

#include<stdio.h>

#include<conio.h>

void main()

{

int bnum,digit,decimal=0,bin,base=0;

printf("Enter the binary number:");

scanf("%d",&bnum);

bin=bnum;

while(bnum!=0)

{

       digit=bnum%10;

       decimal=decimal+(digit<<base);

       base=base+1;

       bnum=bnum/10;

}

printf(“The binary equivalent of %d in dicimal = %d, bin, decimal);

}


OUTPUT

Enter the binary number: 1111

The binary equivalent of 1111 in decimal = 15

 

Computer Programming C Laboratory: Practical C Programs : Tag: C Programming : C Program with Algorithm, Flowchart, Output - Write a C program to find the equivalent decimal value for the given binary number


Computer Programming C Laboratory: Practical C Programs



Under Subject


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



Related Subjects


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