+ 1

Why this code generate f

int main () { int a=15; cout <<hex <<a; } ..Output is.. f Why this code generate f and why not other?

25th Jun 2019, 12:14 PM
Nouman Bin Sami
Nouman Bin Sami - avatar
4 Antworten
+ 3
It's the value of a in hexadecimal
25th Jun 2019, 12:18 PM
Agent_I
Agent_I - avatar
+ 3
std::hex modifies the default base for numeric I/O. So the value 15 is printed in hexadecimal, which is "f".
25th Jun 2019, 12:18 PM
Bebida Roja
Bebida Roja - avatar
+ 1
Nom Butt The question has already been answered. f is 15 in hexadecimal notation https://en.m.wikipedia.org/wiki/Hexadecimal
25th Jun 2019, 3:11 PM
Anna
Anna - avatar
0
25th Jun 2019, 3:09 PM
Nouman Bin Sami
Nouman Bin Sami - avatar