# How to Write a Program That Prints All the Numbers of Base 16 in Lowercase in C

## A Step-by-Step Guide

## Table of contents

## Introduction

Numbers of Base 16 are simply numbers in Hexadecimal, where these numbers range from 0 to 15, but then to differentiate these numbers from the numbers of base 10 (decimal/denary), from 0 to 9 are the normal numerical numbers, while from 10 to 15, they are been represented by normal alphabets starting from A, down to F. This alphabet can either be in uppercase (A, B, C, D, E and F) or lowercase (a, b, c, d, e, f).

The table below shows the entire number of base 16.

Base 10 | Base 16 (uppercase) | Base 16 (lowercase) |

0 | 0 | 0 |

1 | 1 | 1 |

2 | 2 | 2 |

3 | 3 | 3 |

4 | 4 | 4 |

5 | 5 | 5 |

6 | 6 | 6 |

7 | 7 | 7 |

8 | 8 | 8 |

9 | 9 | 9 |

10 | A | a |

11 | B | b |

12 | C | c |

13 | D | d |

14 | E | e |

15 | F | f |

These are all the numbers of base 16.

## Printing Numbers of Base 16 in Lowercase

To pull this off, we will need to make use of our loop, it could be our for loop, while loop or do while loop together with our control statement, which could either be an if-else or a switch statement.

And we could also just ignore all these and used just our loop statement together with the printf function to save ourselves the stress of having to use the control statements.

To use the printf function, we will be using the hexadecimal formatter, which is the `%x`

for lowercase and the `%X`

for uppercase.

So we will loop through numbers from 0 to 15 and print them to the standard output using the printf with the base 16 formatter.

I will still be using the Betty style of coding in C programming.

```
#include <stdio.h>
/**
*main - prints numbers of base 16 in lowercase
*Return: 0
*/
int main(void)
{
int num;
for (num = 0; num <= 15; num++)
{
printf("%x", num);
}
printf("\n");
return (0);
}
```

As you can see from the image above, it printed the numbers of base 16 in lowercase, to do the same in uppercase, simply use an uppercase x instead of a lowercase x for the base 16 formatter in the printf function.

## Conclusion

You can also use different methods for this, but this is the easiest and straightforward method you can find.