Wednesday, December 10, 2014

Decimal To Binary Converter in C++

In this article I would like to share with you a sample program that I wrote in my spare time I called this program Decimal To Binary Converter 1.0 in C++. What does the program will to is to ask the user to enter any integer value and then it will convert into its binary equivalent. The code is very easy to understand and can be used in your programming assignments and activities in C++ programming. In this program I am using CodeBlocks as my text editor and Dev C++ as my C++ compiler. All this software is freely available over the Internet free to download and use.

If you have some questions about my work feel free to send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. I will be happy to read all your emails and suggestions how I can improve my works in programming.

People here in the Philippines who wish to contact me can reach me at my mobile numbers 09173084360 and 09993969756.

Thank you very much and Happy Productive Programming.



Sample Output of Our Program

Program Listing

#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
    char reply;
   do {
    int decimal_number=0, quotient=0;
    int binary_number[100],a=1,b=0;

    system("COLOR 9A");
    cout << "\n";
    cout << "\t================================\n";
    cout << "\tDecimal To Binary Converter 1.0\n";
    cout << "\t================================\n";
    cout << "\n";
    cout <<"Please Enter Any Decimal Number :=> ";
    cin >> decimal_number;

    quotient = decimal_number;

    while(quotient!=0){
        binary_number[a++]= quotient % 2;
        quotient = quotient / 2;
    }

    cout << "The Binary Value of Decimal Number is "
        <<decimal_number << ". => ";
    for(b = a-1 ; b>0; b--) {
    cout << binary_number[b];
    }
   cout << "\n\n";
  cout << "Do you want to continue y/n : ";
  cin >> reply;
   } while(reply=='Y' || reply=='y');
   cout << "\n\n";
   cout << "\t Thank You For Using This Software.";
   cout << "\n\n";
   system("pause");
}



No comments:

Post a Comment