I will discuss how to create a program using C++ to ask the user to give a decimal number and then the program will convert the decimal number into binary number equivalent.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.
Sample Program Output
Program Listing
// binary.cpp
// Author : Jake Rodriguez Pomperada,MAED-IT
// Date : October 12, 2019 Saturday 2:31 PM
// Email : jakerpomperada@gmail.com
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
long int decnum=0,rem=0,quot=0;
int binnum[100], i=1, j=0;
cout <<"\n\n";
cout <<"\tDecimal To Binary Converter in C++";
cout <<"\n\n";
cout << "\tGive Any Decimal Number : ";
cin >> decnum;
quot=decnum;
while (quot != 0) {
binnum[i++] = quot % 2;
quot = quot/2;
}
cout <<"\n\n";
cout <<"\tEquivalent binary Value of "
<< decnum << " : \n";
cout <<"\n";
cout <<"\t";
for (j=i-1; j>0; j--) {
cout << binnum[j];
}
cout <<"\n\n";
cout <<"\tEnd of the Program";
}
No comments:
Post a Comment