Read a decimal number, Converts decimal to octal and hex - C++ File Stream

C++ examples for File Stream:cin

Description

Read a decimal number, Converts decimal to octal and hex

Demo Code

#include <iostream>
using namespace std;
int main() {//from w ww .  j a va2s  .  c  o  m
   int number;
   cout << "Enter a decimal number: ";
   cin >> number;
   cout << "value in octal = 0" << oct << number << endl;
   cout << "value in hex = 0x" << hex << number << endl;
}

Result


Related Tutorials