diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 74 |
1 files changed, 54 insertions, 20 deletions
@@ -1,3 +1,5 @@ +# COMP-325 Assignment 1 + For Assignment 1, you are going to complete the following learning activities taken from your textbook. Use the script command to save the terminal session wherever necessary. Saving the terminal starts with the script filename command and ends with exit. @@ -7,7 +9,7 @@ and upload it here to submit it to your tutor for marking and feedback. Be sure to complete the final step—click on the Send for Marking button to notify your tutor. -1. Solve problems 7–11 and 15–17 at the end of Chapter 7. +## Solve problems 7–11 and 15–17 at the end of Chapter 7. 7. Give three commands that you can use to list the absolute pathname of your home directory. ```bash @@ -117,7 +119,7 @@ chapter8.eps: empty chapter9.eps: empty ``` -2. Solve problems 7–17 at the end of Chapter 8. +## Solve problems 7–17 at the end of Chapter 8. 7. How do the read, write, and execute permissions work in UNIX? Illustrate your answer with some examples. @@ -207,26 +209,58 @@ d. cp /etc/passwd dir1 16. Give chmod command lines that perform the same tasks that the mesg n and mesg y commands do. (Hint: Every hardware device, including your terminal, has an associated file in the /dev directory.) 17. What are the purposes of the set-user-ID (SUID), set-group-ID (SGID), and sticky bits? +## Do problem 9 (What do the following commands do?) in Chapter 9. +## Enter a C program that reads a temperature in Celsius entered from a keyboard and displays the corresponding temperature in Fahrenheit and complete the steps below. +(Hint: Look for such a program in the textbook or online.) +Compile this program using the cc compiler, or any other compiler. Fix any errors, and recompile. +Your program must have declaration statements, such as float c, f; +**Delete the semicolon from the end of the statement.** Recompile and report the kind of error. +The C compiler often provides cryptic error messages. Interpret this message. +**Change the float c, f; statement to (float c; char f;)** -3. Do problem 9 (What do the following commands do?) in Chapter 9. -4. Enter a C program that reads a temperature in Celsius entered from a keyboard and displays the corresponding temperature in Fahrenheit and complete the steps below. -(Hint: Look for such a program in the textbook or online.) -Compile this program using the cc compiler, or any other compiler. Fix any errors, and recompile. -5. Your program must have declaration statements, such as float c, f;. -Delete the semicolon from the end of the statement. -Recompile and report the kind of error. -The C compiler often provides cryptic error messages. -Interpret this message. -6. Change the float c, f; statement to (float c; char f;). -Do you get any errors during compilation? -What are they and why? -Do you see any difference between running this program and the earlier version? Why? -7. If your program uses a cout statement, then replace it with a `printf`statement that does the same thing and vice versa. -8. If you have used neither cout nor printf in the first version, then replace what you have with printf. -9. Explain how you can schedule the executable program to run at 1:00 a.m. and to take the input from a file, rather than the keyboard, without any changes to the source program. -10. Explain how you can find the time it took the computer to execute your program. -11. Explain how the output of your program can be automatically emailed to your friend upon completion. +* Do you get any errors during compilation? +* What are they and why? +* Do you see any difference between running this program and the earlier version? Why? +* If your program uses a `cout` statement, then replace it with a `printf` statement that does the same thing and vice versa. +* If you have used neither `cout` nor `printf` in the first version, then replace what you have with `printf`. + +## Explain how you can schedule the executable program to run at 1:00 a.m. and to take the input from a file, rather than the keyboard, without any changes to the source program. +## Explain how you can find the time it took the computer to execute your program. + +You can use the `time` command. + +E.g + +```bash +も time curl -s -I https://www.mokhan.ca/ +HTTP/2 200 +content-type: text/html +content-length: 8017 +date: Tue, 21 May 2019 08:49:34 GMT +last-modified: Fri, 19 Apr 2019 18:06:57 GMT +etag: "902a8badcb38234a5d17b0f4ad54406e" +accept-ranges: bytes +server: AmazonS3 +vary: Accept-Encoding +age: 7455 +x-cache: Hit from cloudfront +via: 1.1 805232684895bb3db77c2db44011c8d0.cloudfront.net (CloudFront) +x-amz-cf-id: AxXM-x6oQ4RnM_YrQoR0nYtbrVF5mW7pREVHyu5tPD3SNswhLR2h0g== + + +real 0m0.136s +user 0m0.030s +sys 0m0.010s +``` + +The `time` program will emit 3 times at the end of the run. The `real` +time is the total time from invocation to completion. The `user` time is the time spent in user mode. +The `sys` time is the time spent in kernel mode. The difference between +`user` and `sys` shows the amount of time spent in the program version +the `kernel`. + +## Explain how the output of your program can be automatically emailed to your friend upon completion. |
