IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası

IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası (https://www.ircforumlari.net/)
-   C ve C++ (https://www.ircforumlari.net/c-ve-c/)
-   -   Hex, Octal ve Dec arası değişim (https://www.ircforumlari.net/c-ve-c/124385-hex-octal-ve-dec-arasi-degisim.html)

Cemalizim 19 Temmuz 2008 15:40

Hex, Octal ve Dec arası değişim
 
PHP- Kodu:

 //****************************************************************************//
//                                                                            //
// 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 
1clrscr();
                               
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 
2clrscr();
                               
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 
3clrscr();
                               
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;


Alıntıdır


Tüm Zamanlar GMT +3 Olarak Ayarlanmış. Şuanki Zaman: 07:30.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO
Copyright ©2004 - 2025 IRCForumlari.Net Sparhawk