Part 2 You will write a program that takes a user-supplied integer and prints it to stdout in four different formats: signed decimal, unsigned decimal, hexadecimal, and binary. Your main method will read a signed decimal integer from the user through stdin, and then print the number in the four formats. You may assume that the user will enter a valid integer, so no error checking is necessary. Your Makefile should generate an executable called convert. Sample Executions $ ./convert Enter an integer : 1 signed decimal : 1 unsigned decimal: 1 hexadecimal 1 : 0000 0000 0000 0000 0000 0000 0000 0001 binary $ ./convert Enter an intener. -1 hes (33 sloc) 1.9 KB unsigned decimal: 4294967295 hexadecimal : ffffffff binary : 1111 1111 1111 1111 1111 1111 1111 1111 $ ./convert Enter an integer 256 signed decimal : 256 unsigned decimal: 256 hexadecimal binary : 100 : 0000 0000 0000 0000 0000 0001 0000 0000 <> Raw Blame Note that your program must behave EXACTLY the same as the sample executions above. This means that the strings, ordering, and spacing must be the same. Requirements/Tips • The only libraries you can include are stdio.h and stdlib.h. Any other libraries you include will be removed before we test you code. You must use putc to print the binary representation. Use man 3 putc for more information. o For example, to write the character '1' to stdout, use putc('1', stdout) • To convert from decimal to binary, you must use bitwise or bit shifting operations. You must not use the mod (%) operator. • You must use scanf("%d", &x) to read an integer inputted through stdin (into a variable x). Feel free to name the variable however you wish. • There is never a space after the last readable character on a line of output. There is, however, a new-line character after the last binary digit on the last line.
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
Hello, I need help with this C program
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images