Hex, Octal ve Dec arası değişim

Ahbap

Harbi Üye
Forum Üyesi
Katılım
29 Mayıs 2019
Mesajlar
8,562
Tepkime puanı
2
PHP:
  //****************************************************************************//
//                                                                            //
// Program Name : ConvDec.cpp                                                 //
//                                                                            //
//   Programmer : K.Angel                                                     //
//              : Novice C++                                                  //
//                                                                            //
//  Description : The user is asked to input a number in either Hex, Octal or //
//                Decimal, which is then converted to Hex, Octal & Decimal.   //
//                The user can exit the program from the MAIN MENU or by      //
//                the Escape key after each convertion.                       //
//                                                                            //
//     Compiler : Borland Turbo C++ v4.5.                                     //
//         Date : 16/03/2006                                                  //
//                                                                            //
//****************************************************************************//
 
#include <iostream.h>
#include <conio.h>             // for clrscr() & getche() functions...
#include <stdlib.h>            // for exit() function...
 
const int ESC = 27;           // Used for escape sequince
 
int main()
{
     int key = 0;
     int choise = 0;
     long number;
 
     while(key != ESC)
     {
          cout << "Choose Your Number Base\n";
          cout << "\n\t1. Hexadecimal.";
          cout << "\n\t2. Octal.";
          cout << "\n\t3. Decimal.";
          cout << "\n\t4. Exit.\n\t       ";
          cin  >> choise;
 
          switch(choise)
          {
               case 1: clrscr();
                               cout << "Enter a Hex number: ";
                               cin  >> hex >> number;
                               cout << "\n   value in octal = "
                               << oct << number << endl;
                               cout << " value in decimal = "
                               << dec << number << endl;
                               break;
               case 2: clrscr();
                               cout << "Enter a Octal number: ";
                               cin  >> oct >> number;
                               cout << "\n       value in hex = "
                               << hex << number << endl;
                               cout << "   value in decimal = "
                               << dec << number << endl;
                               break;
               case 3: clrscr();
                               cout << "Enter a dec number: ";
                               cin  >> dec >> number;
                               cout << "\n   value in octal = "
                               << oct << number << endl;
                               cout << "     value in hex = "
                               << hex << number << endl;
                               break;
               case 4:  clrscr();
                               cout << "Program terminated by user...";
                               exit(0);
                               break;                 //Unreachable code....  
               default : clrscr();
                               cout << "ERROR ~ Invalid selection\n\n";
                               break;
          }
          cout << "Press any key to continue or 'Esc' to exit";
          key = getche();
          clrscr();
     }
     cout << "Program terminated by user...";
     return 0;
}
 
İçerik sağlayıcı "paylaşım" sitelerinden biri olan Harbimekan.Com Forum, Eğlence ve Güncel Paylaşım Platformu Adresimizde 5651 Sayılı Kanun’un 8. Maddesine ve T.C.K’nın 125. Maddesine göre TÜM ÜYELERİMİZ yaptıkları paylaşımlardan sorumludur. Harbimekan.Com sitesindeki konular yada mesajlar hakkında yapılacak tüm hukuksal Şikayetler için info@harbimekan.com yada iletişim sayfası üzerinden iletişime geçilmesi halinde ilgili kanunlar ve yönetmelikler çerçevesinde en geç 3 Gün (72 Saat) içerisinde Forum yönetimi olarak tarafımızdan gereken işlemler yapılacaktır.

Bu Site, Bilim ve Sağlık Haber Ajansı Üyesidir.

Yığıntı - 8kez - kaynak mağazam - Uğur Ağdaş - genel forum - webp converter