$30
Mini Assignment #3 COMP 206
Sessions and C
Lab D will provide some background help for this mini assignment.
QUESTION 1: The Login Script
For this question you will need to:
- Determine which login script your shell uses when you ssh or putty
- Modify your login script as specified below
- Comment the login script with your changes
- Upload a zipped version of the login script
Modify your login script in all the following ways:
- Display “Welcome <$username to SOCS Bash!”
(from shell memory, check syntax)
- Alias ls -l-a to la
- Set your history to 10
- Set your prompt to: your user name, current directory (dynamic)
- Who | grep one or more of your friends
- Plus one other thing of your liking (make sure to comment this one for the TA)
You can test your login script at the command prompt by using the source command.
If you do not remember this command check our class notes or do man source at the
command line. BUT, you must actually test your login script, in the end, by logging into
your account, to see if the login script you modified is the actual one ssh/putty was using.
QUESTION 2: Your First C Program
Write a C program called: triangles SIZE
Example: ./triangles 3
*
**
***
Where:
• SIZE is the size of the right triangle
Use vi to create the program.
Use gcc to compile the program into the triangles executable name.
The program must do the following in the order presented:
1. If a command line variable was passed to the program then assign the integer
variable size to that value.
2. If there was no command line variable, then prompt the user to input an integer
number for the variable size.
3. The variable size must be greater than zero. If it is not, then display the error
message: “An incorrect triangle size was inputted. The size must be greater than 0
and an integer number. Syntax: ./triangles SIZE”.
4. Using a loop, display the triangle.
5. Program terminates.
Examples:
Size = 1
*
Size = 2
*
**
Size = 3
*
**
***
You must use mimi.cs.mcgill.ca to create the solutions to this assignment. You cannot
use your Mac command-line, Windows command-line, nor a Linux distro installed
locally on your laptop. You can ssh or putty from your laptop to mimi, or you can go
to the third floor of Trottier and use any of those labs, to complete this assignment.
WHAT TO HAND IN
Everything must be submitted to My Courses before the due date. Remember that you
can hand in your assignment up to two days late but there will be a penalty of 5% each
day. After that, your assignment will not be accepted. Please hand in the following:
• The login script file
• The C program source file: triangles.c
• Do not hand in the executable, but hand in a readme.txt file with
the gcc command you would use to compile triangles.c
• Zip all these files so that myCourses will receive them correctly.
• Make sure to add comments to your script and C program.
• Add you name and student ID number as a comment.
HOW IT WILL BE GRADED
THE TESTING SCRIPT
The TA will run a testing script when evaluating your assignment. This test script is
included in the assignment. You can use this testing script as you write your solution to
verify that your program runs correctly. The script file is called mini3tester.sh.
POINTS AWARDED
The assignment is worth a total of 20 points.
o 10 points for Question 1
• 2 point – correct login script
• 1 point – Welcome echo
• 2 point – Alias
• 1 point – History
• 2 point – Prompt
• 1 point – Who | grep
• 1 point – One other of your own choosing
o 10 points for Question 2
• 2 points – command line argument
• 2 points – prompt to read size
• 1 point – Checking for the command line argument
• 1 point – Checking size 0 with error message
• 4 points – Correctly printing out triangles
GRADING RULES
The following rules are followed by the TA when grading assignments:
• A program must run in order to get a grade (even if it does not run well). If it
does not run (does not compile) it will receive a zero. (Make sure to run your
programs from mimi.cs.mcgill.ca).
• The TA will grade using the mimi.cs.mcgill.ca server.
• All questions are graded proportionally. This means that if 40% of the question is
correct, you will receive 40% of the grade.