1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[]) {                    // C integer literal
    printf("twenty-two in base 10 is written \"%d\"\n",   22);  // base 10

    printf("twenty-two in base 10 is written \"%d\"\n", 0x16);  // base 16
    // 0x  is a prefix that means the rest will be base 16 (hexadecimal)
    // 1   means 1 x 16 because that is the "16s place"
    // 6   means 6 x  1 because the rightmost digit is always the "1s place"
    // ____________
    // 1 x 16 + 6 x 1 = twenty-two

    printf("twenty-two in base 10 is written \"%d\"\n",  026);  // base  8
    // 0  is a prefix that means the rest will be base 8 (octal)
    // 2  means 2 x 8 because that is the "8s place"
    // 6  means 6 x 1 because the rightmost digit is always the "1s place"
    // ____________
    // 2 x 8 + 6 x 1 = twenty-two

    //printf("twenty-two in base 10 is written \"%d\"\n", 10);
    return EXIT_SUCCESS;
}
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */

© Copyright 2020 Alexander J. Quinn         This content is protected and may not be shared, uploaded, or distributed.