This Post Contains A C++ Program For Conversion Of Binary No. Into Decimal No With Correct Source Code & Output. This Program Is Written, Compiled & Executed At TurboC3.0 Compiler & Will Help You To Understand The Concept Of 'Arrays' & 'While-loop' From C++ Language. It Is A Well-Structured Program With Proper Comments Which Provides Step-By-Step Description Of Various Features Of The Language In A Simple & Easy-To-Understand Way.
# Note : You Can Simply Copy-Paste The Following Program Or Code Into Compiler For Direct Result.
C++ Program For Conversion Of Binary No Into Decimal No.
/* Declaration Of Header Files */
# include <iostream.h>
# include <conio.h>
# include <math.h>
/* Start Of Main Program */
void main()
{
/* Declaration Of Variables */
int p, q, r, b[20];
long Num;
clrscr();
/* Asking For The Input From User */
cout << " Enter Any Binary Number : ";
cin >> Num;
/* Source Code For Computing Conversion Of Binary Into Decimal */
p = 0;
while ( Num > 0 )
{
b[p++] = Num % 10;
Num = Num / 10;
}
q = p - 1;
r = 0;
while ( q >= 0 )
{
r = r + ( b[q] * pow ( 2 , q ) );
q--;
}
cout << r;
getch();
}
/* End Of Main Program */
# Note : You Can Simply Copy-Paste The Following Program Or Code Into Compiler For Direct Result.
C++ Program For Conversion Of Binary No Into Decimal No.
/* Declaration Of Header Files */
# include <iostream.h>
# include <conio.h>
# include <math.h>
/* Start Of Main Program */
void main()
{
/* Declaration Of Variables */
int p, q, r, b[20];
long Num;
clrscr();
/* Asking For The Input From User */
cout << " Enter Any Binary Number : ";
cin >> Num;
/* Source Code For Computing Conversion Of Binary Into Decimal */
p = 0;
while ( Num > 0 )
{
b[p++] = Num % 10;
Num = Num / 10;
}
q = p - 1;
r = 0;
while ( q >= 0 )
{
r = r + ( b[q] * pow ( 2 , q ) );
q--;
}
cout << r;
getch();
}
/* End Of Main Program */
No comments:
Post a Comment