Classwork 4: More input, output, and operators
Thursday, July 12, 2012[Previous Classwork] [Next Classwork]
Complete the following:
- Ensure the machine is booted into Linux
- Login to Linux
- Open a termimal from the top left Applications menu -> System Tools -> Terminal
- Create a directory (using mkdir) called cw04 to store this classwork
- Go into your new cw04 directory (using cd)
- Create a new file using the editor you like (nano, vi, emacs, xemacs) called cw04.c
- Type a comment for the header based on the template below:
/* File: cw04.c Name: A. Student Username: astudent1 Date: 10/24/07 Description: ... */
- Type in the appropriate #include to use printf and scanf
- Create the main block (make sure to have { after main, and } at the end of your code)
- Then write code inside main to:
- Before you start writing code, read through what the program will do and decide how many and what type of variables you will need.
- Print out the following string "Starting cw04\n" at the start of your progam
- Print out a string asking the user to input two integers (use printf)
- Allow the user to input two integers (use scanf)
- Print out the integral result of dividing the first integer by the second (use division operator /)
- Print out the integral remainder when dividing the first integer by the second (use modulus operator %)
- Remember to return zero at the end of main
- Remember to use the following command to compile your program as shown below
linux2[107]% gcc -Wall cw04.c -o cw04
- And then run your program as shown below
linux2[108]% ./cw04 Starting cw04
- Once you are sure the program is done and working well, start a script using script
- Once the script is running, show you compiling your program, and then running the program three times, typing in different values each time.
- Exit from the script, which will save the log typescript
- Once you are done, use submit to submit two files, cw04.c and typescript
linux3[26]% submit cs104 cw04 cw04.c typescript
- After submitting your files, you can verify your files were submitted by using the submitls command as shown below
linux3[26]% submitls cs104 cw04
- MAKE SURE YOU LOGOUT AFTER SUBMITTING THE ASSIGNMENT AND BEFORE LEAVING CLASS!