ASCII Bits & Bytes Solution




In this introductory assignment, you will write a complete C program that will prompt the user to enter an ASCII printable character (note the decimal range should be between 0 and 127, inclusively) and then print out its decimal (base 10), hexadecimal (base 16), octal (base 8), and all eight bits in its binary (base 2) representation.

You may assume that the user enters a valid ASCII printable character when prompted.

Although not required, you may find Chapter 2 on Bits, Bytes, and Data Types in the System Programming with C and Unix optional reference textbook by Adam Hoover to be helpful.


  • Your code should be well documented in terms of comments. For example, good comments in general consist of a header (with your name, course section, date, and brief description), comments for each variable, and commented blocks of code.

  • Your program should be named “minor1.c”, without the quotes.

  • Your program will be graded based largely on whether it works correctly on the CSE machines (e.g., cse01, cse02, …, cse06), so you should make sure that your program compiles and runs on a CSE machine.

  • This is an individual programming assignment that must be the sole work of the individual student. Any instance of academic dishonesty will result in a grade of “F” for the course, along with a report filed into the Academic Integrity Database.

SAMPLE OUTPUT (user input shown in bold green):

$ ./minor1

Enter an ASCII character: A

The ASCII value of A is:

dec — 65

hex — 41

oct — 101

bin — 01000001

$ ./minor1

Enter an ASCII character: a

The ASCII value of a is:

dec — 97

hex — 61

oct –- 141

bin — 01100001



  • You will electronically submit your program to the Minor Assignment 1 dropbox in Canvas by the due date and time.