Question
Please answer in C code. Write a printTable function that prints a table of characters, along with their ASCII code values in various bases. The
Please answer in C code.
Write a printTable function that prints a table of characters, along with their ASCII code values in various bases. The function takes as arguments a start value and an end value and prints all the characters whose ASCII codes are in the range from start to end inclusive. Your function should print out the column headings at the top of the table. The base values are binary, octal, decimal, and hexadecimal. The function should format the output according to the sample outputs below. Additionally, your function should do input validation on the arguments:
- start and end must be in the range from 32 to 126
- start must be
If any of the arguments is invalid, the function should print an error message, according to one of the sample outputs below. Then demonstrate your function with a main function that calls your function.
Hints:
- Use the for loop.
- You can write a function that takes as argument an int and prints the binary representation of the int argument.
Sample Outputs:
Enter start and end values, range is 32 to 126 inclusive: 106 126 Binary | Oct | Dec | Hex Char] [ Binary | Oct | Dec Hex Char] [ 01101010 | 152 | 106 | 62 | j] [ 01101011 | 153 | 107 | 6b | k] [ 01101100 | 154 | 108 | 60 | 1 ] [ 01101101 | 155 | 109 | 60 | m] [ 01101110 | 156 | 110 | 6e | n] [ 01101111 | 157 | 111 | 6 | O] [ 01110000 | 160 | 112 |70| p ] [ 01110001 | 161 113 171 | q] [ 01110010 | 162 | 114 172 | r] [ 01110011 163 | 115 | 73 | S] [ 01110100 | 164 | 116 174 | t ] [ 01110101 | 165 | 117 175 || u ] [ 01110110 | 166 | 118 176 | v ] [ 01110111 | 167 | 119 177 | W] [ 01111000 | 170 120 | 78 | x] [ 01111001 | 171 | 121 179 | y] [ 01111010 | 172 I 122 17a | z ] [ 01111011 | 173 123 |7b|| {] [ 01111100 | 174 | 124 170 | ] [ 01111101 | 175 | 125 |7d | } ] [ 01111110 | 176 | 126 17e | ~] Enter start and end values, range is 32 to 126 inclusive: 126 25 Invalid value (s)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started