Using the value -35, write it as binary and hexadecimal formats.

Home » C++ programming language

Traditionally, cout reads/writes values in Decimal format. To read/write values in other Base formats like 'Octal Base format', 'Hexadecimal Base format', there are some C++ manipulators [Read: other C++ Manipulator]

dec - for Decimal Base format
oct - for Octal Base format
hex - for Hexadecimal Base format

Example:

In this example, we will print [write] the value of a variable named var [the value of var is 100 in Decimal Base format] in Octal Base format, Decimal Base format and Hexadecimal Base format.

#include 
using namespace std;

int main[]
{
	int var=100;
	cout

Chủ Đề