CS 15900 - Lab #0

Final submission due: 30 minutes before your lab meets for the week of January 15

Individual assignment

Click here to open these instructions in a new tab.


Contents

1.   Getting started

Welcome to CS 15900! One of the three credit hours assigned to this course is devoted to a weekly two-hour lab period. These labs will be an opportunity to learn new material, to review content from previous lectures, and to create new programs in a collaborative environment with your fellow students.

The tasks that follow are designed to help you become familiar with how you will be completing programming assignments in this class - including both lab assignments (which are completed in teams of students) and homework (which are completed individually). The tasks in Lab #0 will be individual as well, but feel free to ask your neighbors, teaching assistant, or Ed for help.

You must understand these instructions in order to be able to complete future assignments, so take your time and revisit these activities as necessary.

2.   Submitting attendance

Note

If you are not physically present in your lab section’s room during its class time, you may skip this section since you will not be able to complete it. However, you must submit attendance starting with Lab #1 or risk losing points.

CS 15900 uses a digital attendance tracking system called the lab manager, where students log their own attendance status to be reviewed by their lab instructor. The lab manager only allows students to submit attendance from ITaP computer workstations located within their lab section room of record during the times in which the lab section is holding class.

Specifically, you can mark yourself as “on-time” beginning 5 minutes before your lab section starts, and up until 5 minutes after it starts. As an example, for a lab section that starts at 9:30 AM, you would be able to mark yourself as “on-time” anywhere between 9:25 AM and 9:35 AM.

After 5 minutes of the class have elapsed, you may only be able to mark yourself as “late”. After the class ends, you will not be able to submit attendance for this assignment at all.

Warning

As noted in page 2 of the class syllabus, students late or absent to more than two lab sessions will automatically fail the course.

It is therefore critical that you log in to the lab manager at the start of every class and mark yourself as on-time.

If you are considered late during a normal lab period (excluding today), you will forfeit your points for the lab programming assignment, but can still receive full points for the lab quiz.

If you are considered absent, you forfeit points for both the lab programming assignment and the lab quiz.

Your lab instructor and lecturer have the ability to override your attendance status if there is a technical issue regarding your ability to access the lab manager, or if you have an excused reason to be late. For all other issues, lab instructors are only allowed to give you one override per semester.

Every lab programming assignment instructions document will contain a link at the top to the lab manager so that you may mark yourself as on-time for the assignment. It is your responsibility to remember to do so.

You can log in to the lab manager and submit attendance for an assignment by clicking the following link. You must log in from an ITaP computer workstation in your lab section’s room.

https://www.cs.purdue.edu/cs159/lab/submit_attendance.php

You should be presented with a screen similar to the following:

student_attend_preview.png

Your pending attendance status for each assignment is shown next to the assignment name. Here, a green “On-time” box next to “Lab #0” indicates that we are in the correct room at the correct time. However, the black “Not submitted” box indicates that you have not yet submitted attendance for this assignment.

Note

For Lab #0 only, it is okay if the lab manager believes you are late since this is your first time using it.

Click the checkbox next to “Lab #0”, then click the “Submit” button. If the submission was successful, a green confirmation box will appear near the top of the screen indicating as such, and a green “Already submitted” box will replace the black “Not submitted” box in the assignment list.

student_attend_submitted.png

You will also receive a confirmation email from cs159-wiki@cs.purdue.edu.

By clicking the blue “CS 15900 lab manager” heading you can access the lab manager’s homepage. This includes a link to the page you were just on (“Submit attendance for an assignment”) as well as another link (“View my attendance records”, which you can access from any computer - not just ones in your lab).

STOP!

Raise your hand and ask your lab instructor to verify that you have completed the first checkpoint: attendance. They will check that your attendance record is in the lab manager.

3.   Logging into Vocareum

Note

If you have not yet bought a Vocareum license, please follow this guide.

All programming assignments are completed using a website called Vocareum. Your access to Vocareum is controlled by the CS 15900 course on Brightspace - always log in there first if you haven’t already.

Navigate to “Content”, then “Week 1”, then “Assignments”. Open the link that says “Lab #0 (Vocareum)”. Your account with Vocareum will automatically be created.

Note

Vocareum is not part of Purdue’s single sign-on system. Each time you need to log in to Vocareum, you must do so using a link from Brightspace. You cannot login to Vocareum directly.

4.   The student workbench

Clicking the Brightspace links open what is called the “student workbench”. It is from here that you will develop and submit all of your assignments.

student_workarea.png

Note

If there is a message saying “launch failed with exit code -1” or “no server is available to handle this request”, try refreshing the page.

The top right side of the screen has several buttons that can be used.

student_workarea_controls.png

The left hand side of the screen is the interactive terminal - essentially a text-based user interface for the remote computer on which you will be doing your work. Shown below is the terminal command prompt.

student_workarea_prompt.png

The prompt consists of your Purdue username in gold, the current assignment name in blue, and a dollar sign. When you begin typing, the characters you enter will appear after the dollar sign. This is where you can enter commands that the remote computer will perform (or “execute”). The black box indicates the position of your cursor (i.e. where the next character you enter will appear).

Note

If the text in the terminal is too small for you to comfortably read, you can use your browser’s zoom feature to make the text appear bigger. This is usually accomplished by holding down the Control key and pressing Shift and = (i.e. +), or using Command instead of Control for Macs. To zoom back out, use - instead of Shift =.

6.   Opening the “vi” text editor

A text editor is a program you use in order to edit text-based files. This is similar in concept to Microsoft Word, except that there is no bold, underline, etc. - all of the text in the file is “plain text” (has no formatting).

The vi (pronounced vee-eye) text editor will be the one officially supported by the course. This particular editor has a text-based user interface (TUI) instead of a graphical user interface (GUI). However, vi does have many of the tools and capabilities that we find in popular graphical text editors. The editor does take time and practice to learn and to use, but we believe that you will find the effort to be beneficial as the semester progresses, especially since vi is available on practically every existing UNIX-like operating system out-of-the-box.

Warning

Other text editors will not be supported, especially during labs and office hours.

To launch the vi text editor and open the existing round.c file, type vi round.c at the terminal command prompt. This tells vi to try to open the file named round.c, or to begin working on a new file with that name if it does not yet exist.

student_workarea_vi_cmd.png

Once you hit the “Enter” key, a screen like the following is shown in your terminal.

student_workarea_vi.png

Note

For this lab, we have provided you with a file from which to start. In the future, you will still execute the same command to start your assignment (e.g. vi lb01.c or vi hw01.c), but you will be shown a screen of just tildes (~) since the file does not exist and a new file is initially empty.

The blue bar at the bottom is called the status line and tells us information about the file we are currently editing, including its name, the coordinates of the cursor in rows and columns, and the last modification time of the file. Specifically, [0001, 0001] indicates that our cursor is positioned on the first row of text, in column one.

The line of text directly below the status line, known as the vi command line, states there are a total of 226 characters of text in the file, spread across 13 lines.

Above the status line is the contents of the file. The light blue tildes (~) near the bottom indicate that there isn’t enough lines in the file to fill the whole terminal screen, so the last real line of the file is the closing brace (}) on a line by itself just after the return 0;.

The colors of various parts of the text inside the file is known as syntax highlighting. It’s not part of the file itself, but rather vi recognizing that this is a C source file and coloring the different parts as a visual aid for the programmer.

We will cover how to use vi in a later section. For now, hit the Escape key, then type :q! and hit the Enter key to exit vi and return to your terminal command prompt.

student_exited_vi.png

7.   Compiling your program

If you have programmed before, C might be slightly different from what you have previously experienced in that it is a compiled rather than interpreted language.

What this means for students both experienced and new to the C programming language scene is that your program must be compiled after each change you make to the source code. Compilation translates the human-readable source code into a binary “executable” file that the computer can then run as a program.

In this class we will use the GCC compiler, which can be accessed using the gcc command from the terminal command prompt.

To compile your program, type gcc round.c and hit the Enter key.

student_workarea_gcc.png

Here we see that the gcc command did not give any output. This is actually a good thing! It means that there weren’t any issues compiling your program. When we run the ls command again, there is now a new file:

student_workarea_ls2.png

This new file is named a.out, which is the default executable filename GCC uses if none is provided.

8.   Executing your new program

To run our newly-compiled program, type a.out and hit the Enter key. This command will execute the file named a.out in the current directory.

student_workarea_prog1.png

Notice that the terminal command prompt does not appear again. This is because the program is still executing - in fact, it’s waiting for you to enter a number.

Note

In CS 15900, all programs you create will use this arrow notation (->) to indicate that the user must enter a value for the program to continue.

The goal for this program is to output whatever numbers the user enters, but rounded to the nearest tenth. Type 1.06 and hit the Enter key.

student_workarea_prog2.png

The program returns the value 1.1 and returns us to the terminal command prompt, indicating the program has finished executing.

Note

If you ever want your program to stop executing immediately and return to the terminal command prompt, hit Control-C.

9.   Submitting an assignment

When you are ready to submit your assignment, you can click the “Submit” button at the upper right hand corner of the workbench. Vocareum will ask you if you are sure - click the blue “Yes” button.

As the submission is processed, a spinning icon will appear next to the “Submission report” button.

student_workarea_submitting.png

Once the submission is fully processed, this icon will disappear. You can then either click the “submission report” button to view the results of your submission attempt in a rich-text format, or run vi submit.rst to view a plain-text version.

Clicking the “submission report” button replaces the lab instructions with the following screen.

Note

Once you are done reading the report, you can click the “Readme” button to return to the lab instructions.

student_workarea_submit_fail.png

In this case, the submission was not successful because the computer could not find the file lb00.c. Note that this is short for “Lab #0” and thus starts with a lowercase “L”, not a digit one!

Warning

If the submission report says that the submission failed for any reason, then no credit will be given for that submission!

Only the most recent submission is retained and graded, so be careful to always make a successful submission each time. In general, submissions can fail for any of the following reasons:

  • The required source file is not present, does not have the correct name, or is not the right type of file.
  • The program failed to compile.

Let’s change the name of our round.c file to lb00.c so that we can make a successful submission. Run mv round.c lb00.c at the terminal command prompt to do this. If successful, no output will be generated. You can then run ls again to confirm that file has been renamed, or vi lb00.c to view the contents of the renamed file.

student_workarea_mv.png

10.   Resubmitting an assignment

Once you are ready to submit again, just click the “Submit” button once more and confirm that you are ready to submit.

In order to verify that a submission is successful, you must view the submission report (either using the “submission report” button or using vi submit.rst) and look for Your submission has been recorded at the bottom.

student_workarea_submit_success.png

The submission report will also be sent via email from cs159-wiki@purdue.edu to yourself and all members of your team, if applicable.

You can submit your assignment as many times as you like, up until the submission deadline.

Always make sure your program compiles first before submitting the assignment using the gcc command. Submissions that fail to compile will not be given credit.

We will next discuss how to fix the failing test cases and remove some of the deductions listed above.

STOP!

Raise your hand and ask your lab instructor to verify that you have completed the second checkpoint: submission. They will want to see the confirmation email you received.

11.   Interpreting submission reports

CS 15900 has an “auto-grader” that processes each student’s submission and assigns a preliminary grade which is based on the results of test cases run against your submission (output), the technique of your solution, and the formatting of the source code. The submission report gives you an idea of what you should expect the auto-grader will do when it presents your assignment to your lab instructor for final review.

The result of each test is either pass or fail, but you get partial credit depending on how much of the output from your program is considered “correct”.

In this example, we have failed all three test cases. Let’s look at the results for test #01 from the submission report. You can view these results yourself using the “submission report” button, or by running vi submit.rst. The snippets below are from the latter, but both sources contain the same information - just in different formats.

The first section shows us the test number, what the full command was to execute your program, and any input that was given. In this case, we see that the auto-grader passed the value 1.23 to the program:

==========
 Test #01
==========
:Command: ::

  | 'lb00.elf'

:Input: ::

  | 1.23

The next section shows us the status of the test. Here, the test failed because the output of your program did not exactly match the output of the solution program:

:Status: FAILED
:Error: program gave incorrect output

When a test case fails, the auto-grader will then include the output from your program, as well as the output from the solution program:

-------------
 Your output
-------------
::

| Enter measurement ->
| -=-=-=-=-=-=-=-=-=-
| The measurement is: 1.2

-----------------
 Expected output
-----------------
::

| Enter measurement ->
| -=-=-=-=-=-=-=-=-=-
| The measurement rounded: 1.2

If you look at these two outputs carefully, you should notice that the difference is that your program says “The measurement is:” while the solution says “The measurement rounded:” The Difference section visualizes this discrepancy in a text-based format:

------------
 Difference
------------
::

| Enter measurement ->
| -=-=-=-=-=-=-=-=-=-
| The measurement [-is:-]{+rounded:+} 1.2

Here, the auto-grader is telling you to delete is: and put rounded: in its place.

In general, anything between [- and -] should be removed, and anything between {+ and +} should be added.

After the final test case, if there are formatting problems or other issues with how you wrote your source file, the auto-grader will say Course standards violations detected:

======================================
 Course standards violations detected
======================================

------------------
 Format
------------------
:-0.75: Almost no comments present in the program
:-0.50: Missing program header block comment as the first item, line 1
:-0.10: Missing proper variable declaration comment, line 5

This says that if the submission were to be graded right now, you might lose 0.75 points for not including a sufficient number of comments in the program, 0.5 points for not including a program documentation header, and 0.1 points for specifically not putting a comment next to the float measurement; variable declaration on line 24.

12.   Making changes to your program using “vi”

In order to remove these preliminary deductions from our submission, we need to change our source code and resubmit. Run vi lb00.c again to open vi and edit the source file.

When you begin the vi text editor you will find yourself in normal mode. In this mode you are able to issue commands such as to copy and paste, save changes, find and replace, and make other edits.

Complete the following:

  1. Type gg. This command will bring you to the first line of the file. You can also use your “up” arrow key until your cursor is on the first line.

  2. Type :hlb (“:HLB”, but all lower case) and hit Enter. This will insert the course’s standard documentation header for lab programming assignments.

    Note

    For homework assignmens, use :hhw instead.

    Your source code file will now resemble the following:

    student_workarea_hlb.png
  3. Notice that the text that the :hlb command inserted is all blue. This is vi’s way of denoting text that is ignored by the computer, which is called a “comment”.

  4. Next, move your cursor to the line for the lab number. You can do this by pressing k ten times, or press the “up” arrow key ten times.

  5. Press l or the “right” arrow key eight times to move your cursor towards the end of the line.

  6. Pressing the i key will start insert mode, which is how you type content into the file itself. This is indicated by -- INSERT -- appearing below the status line.

    student_workarea_insert.png

    You can now type freely and any text you enter will appear in the window as a new part of the file. You can also use your Backspace key to delete the character that is immediately to the left of your cursor.

  7. Type space-zero-zero next to Lab #: so that it reads Lab #: 00.

    Note

    You may need to use your arrow keys to move your cursor so that you start typing AFTER the colon.

  8. Use the arrow keys on your keyboard to move your cursor to the line that reads Program Description:.

  9. Type a sentence or two describing the purpose of this program, such as "Rounds a user's measurement to the nearest tenth."

    Note

    To paste into the Vocareum terminal, right click anywhere inside the terminal window and select “paste”.

    Selecting text with your cursor will automatically copy it.

  10. At this point, we have completed the program documentation header which will remove the 0.5 point deduction we had on our last submission.

  11. Use your arrow keys to navigate to the line that reads float measurement;. To the end of this line (after the semicolon), type space followed by // user-provided measurement. This will remove the 0.1 point deduction.

  12. Finally, use your arrow keys to navigate to the line that reads The measurement is and change is to rounded. This will fix our failing test cases.

  13. Hit the Escape key to return to normal mode. Notice that -- INSERT -- is now gone from vi’s status line.

  14. Note that there is now [+] located next to the ~/lb00.c filename in the status bar. This indicates that you have unsaved changes.

    At this point, the contents of your file should look roughly like the following:

    student_workarea_normal.png
  15. Type :w and hit Enter to save your changes. The [+] indicator will disappear, and a message below the status line will show that the file was “written” (saved) successfully.

    Warning

    Your changes are not saved automatically, so you should periodically Escape and :w / Enter to save them as you work on your program. Failure to do so could result in the loss of your changes should your computer disconnect from Vocareum for any reason.

  16. You can type :q and hit Enter to exit vi now.

    Note

    If you want to quickly save your changes and exit vi at the same time, you can combine :w and :q into :wq.

    If you want to exit without saving your changes, use :q! instead of :q. Note that this will not ask you to confirm, so be careful that this is what you want!

  17. Try running gcc lb00.c to make sure your program compiles successfully. If no output is generated and the next line of text is your terminal command prompt again, you have succeeded.

  18. Once successfully compiled, you can run a.out again to verify that our changing of is to rounded has taken place.

    student_workarea_fixed.png
  19. If you resubmit your assignment at this point, all of your test cases should now pass, and most of the deductions should now be gone.

13.   Viewing your grades and lab instructor feedback

In general, each homework assignment is worth 10 points (2 points for formatting, 4 points for technique, and 4 points for output) and each lab assignment is worth 5 points (1 point for formatting, 2 points for technique, and 2 points for output).

Note

All lab and homework grades are reviewed by your lab instructor for accuracy, and they are allowed to override the auto-grader - either to give you back some points or make additional deductions. Any questions regarding programming assignment grades should be directed at your lab instructor.

After the submission window for an assignment closes, the auto-grader will be run against the submissions from all students. These preliminary grades may be immediately visible inside Vocareum. Your lab instructor will then review all of the grades for your section for approval and make any changes if necessary. Once they are finished, you will receive an email that your grade has been finalized on Vocareum. Any grade that you see on Vocareum before you receive notification from your lab instructor that your grade has been finalized must be considered a preliminary score only and is subject to change.

The email from your lab instructor will contain a link to the guide on viewing programming assignment grades.

14.   Course policies regarding programming assignments

Purdue research indicates that automated resources such as ChatGPT produce code that is incorrect 52% of the time - worse than a fair coin flip.

It has become clear from previous semesters that these tools produce more harm than help to students enrolled in CS 15900. It is obvious to course staff when novice programmers submit code that utilizes concepts beyond what has been covered in the course - which is listed as prohibited on every assignment. As is the case with accessing any external source for assistance, if you are unable to create the work yourself, then it is unlikely that you are able to disguise it as your own.

When developing your programming assignment solution, please keep in mind that the utilization of any third-party programming assistance services, code repositories, or online integrated development environments (including but not limited to Chegg, CourseHero, Stack Overflow, GitHub, and Replit) is expressly prohibited.

All work on course programming assignments should be derived only from the course notes, the textbook, and any assistance obtained from current course staff members during office hours or via Ed. For homework assignments, this excludes assistance from anyone else (including but not limited to other students in the course, students who have taken the course previously, students who have never taken the course, former course staff members, roommates, romantic partners, family members, and tutors). YOU MUST COMPLETE YOUR OWN WORK!

Warning

For these reasons and more than can be listed here, always be prepared to defend your algorithms and provide documentation that demonstrates the history of development when an instructor requests to know more about your solution.

It is our expectation that all work for CS 15900 programming assignments is completed within the Vocareum development environment provided to you. Submissions that provide little history of development within Vocareum may merit additional scrutiny from members of the course staff.

Our recommendations are the following:

15.   Completing the lab quiz

At the end of each lab session, your lab instructor will direct you to take your lab quiz. These quizzes are worth 5 points each and are based on the content of the written lab problems given in the lab assignment handout. Your lab instructor must proctor these quizzes - you may not take them on your own time.

Warning

For Lab #0 only, you may take this quiz once you reach this point. All other lab quizzes must be taken at the time your lab instructor designates. You will lose credit for lab quizzes taken outside of your lab instructor’s guidance, and such actions may result in academic integrity investigations.

Return to the “Week #1” content module on Brightspace, where you should find “Lab Quiz #0”.

The following restrictions are in effect for all lab quizzes, unless you have accommodations on file with the Disability Resource Center AND have discussed your accommodations with your LECTURER:

Click the blue “Start Quiz!” button to begin the quiz once you are ready.

STOP!

Once you submit the quiz, raise your hand and ask your lab instructor to verify that you have completed the third and final checkpoint: quizzing. They will look for your lab quiz confirmation screen.

16.   Reviewing lab quiz answers

Lab quiz answers will be automatically released to all students at 3:30 PM on Fridays once all lab sections have finished taking the quiz.

Note

For Lab Quiz #0, the answers will be released immediately so that you may become familiar with how to access them.

  1. Click “Course Tools” in the black Brightspace menu bar and select “Quizzes”.

  2. Next, click the arrow icon next to the quiz name for which you want to review your answers. Click “Submissions”.

    student_quizzes.png
  3. Click “Attempt 1”.

  4. You can now see which questions you got correct, which questions you missed, and what the correct answers are for each question (indicated by a blue arrow).

    student_quiz_attempt.png

17.   Creating teams

For information on how to create teams in Vocareum for your lab programming assignments, please review this document.