Q:

C++ program to demonstrate example of setbase manipulator

belongs to collection: C++ Manipulators programs

0

C++ program to demonstrate example of setbase manipulator

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

setbase manipulator program in C++

/*C++ program to demonstrate example of setbase manipulator.*/
/*
 * setbase defines the base value of the value, in which you want to print
 * the value, you can pass 8 for octal, 10 for decimal and 16 for hexadecimal.
 */
 
#include <iostream>
#include <iomanip>
using namespace std;

/*This program will show you to print decimal values in other format*/

int main()
{
	int x=12349;
	cout << "Octal       value is: " << setbase( 8) << x << endl;
	cout << "Decimal     value is: " << setbase(10) << x << endl;
	cout << "Hexadecimal value is: " << setbase(16) << x << endl;
	return 0;
}
 
    Octal       value is: 30075
    Decimal     value is: 12349
    Hexadecimal value is: 303d

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

<< C++ program to demonstrate example of setprecision...