You will write 3 short programs in C using cygwin/gcc as your development environment. You may work together with a partner (or two) if you want, but make sure that each of you fully understands what is happening in the lab. The lab is NOT submitted.
Some guidelines for using unix command line (like cygwin) can be found here. There is also a cheat sheet for compiling with gcc here.
Your C programs will use the input functions scanf and gets. I will briefly describe them here.
scanf is more or less the input equivalent of printf, where it reads a value for each % element if the format string. For example,int num;
gets reads an entire string into a char array. For example,char buffer;
Your program should prompt the user for a number and then print the number out in unsigned decimal and in hexadecimal. An example run would be:$./covert.exe
You should obviously test it with some other values as well, including a negative number.
Your program should prompt the user for a string and then print each character out in hexadecimal and decimal. An example run would be:$./string.exe
Again, test this with a number of different inputs.
Read the code in the attached C file. What do you think it will display if you give it a string longer than 3 characters? Compile this code into a program and try giving it different length strings as the input. Do you understand what it is doing?
Now swap the order of the two variables (num and buffer) in the breakit method. Do you think this will do anything different? Why or why not?
Rebuild the program with the swapped order and try different length strings again. Do you understand what it is doing now?
Talk to your instructor when you are either hopelessly confused or think you understand.