0% found this document useful (0 votes)
4 views2 pages

FPL Tutorial 8

This document presents a tutorial for developing a C program that converts a binary number, inputted as a string by the user, into its decimal equivalent. It includes input validation to ensure that the binary number consists only of '0's and '1's. The program is written by Yuvraj Ritesh Gawande and includes a sample code implementation.

Uploaded by

bj01abc
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

FPL Tutorial 8

This document presents a tutorial for developing a C program that converts a binary number, inputted as a string by the user, into its decimal equivalent. It includes input validation to ensure that the binary number consists only of '0's and '1's. The program is written by Yuvraj Ritesh Gawande and includes a sample code implementation.

Uploaded by

bj01abc
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Tutorial No : 8

Tutorial Title:Develop a C program that converts a binary number (entered by the user as
a string) to its decimal equivalent. Validate the input to ensure it contains only '0's and '1's

Name:Yuvraj Ritesh Gawande

Class:ET1​ Div:ET1​ PRN No:B25ET1010​ Batch:A

Program:

#include <stdio.h>

void main()

char b[10];

int i,d=0;

printf("Enter a binary number:");

scanf("%s",b);

for(i=0;b[i]!='\0';i++)

if(b[i]!='0' && b[i]!='1')

printf("Invalid no.!!");

break;

d=d*2+(b[i]-'0');

}
if(d!=0)

printf("Decimal no. is %d !",d);

Output:

You might also like