Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Lab 4

Submit the source files you wrote, and the screenshot of the results, to TA
through DingTalk message.
(Please create a zip file containing the C files and screenshot, filename format:
“student number + name.zip”)

It is encouraged to finish the lab section in class, though the submission


deadline is 23 Mar.

Part 1: Find out the hex numbers


You are given the following integer numbers, please write a C program to find
out their hex numbers and show them on the screen.
(Fill the blacks in the following table using the results observed from the
screen)

interger
0 10 16 160 -1 -2 -160
number
hex number

Also, think about another question. Is there any difference between the hex
format of positive and negative numbers? If yes, try to figure out the principles
of converting a negative number to its hex format, and write it down in your
report.
Part 2: Simple Arithmetic
Write a C program which can accept input of two integer numbers from the user,
and then add them up, show the result on the screen.
(Operation tips should be provided as guidance of the program)

Example output:

You might also like