School of Computing
College of Engineering
University of Nebraska-Lincoln
This lab introduces you to your programming environment and the software development workflow and handin/grading process used by this course.
In each lab there may be pre-lab activities that you are required to complete prior to attending lab. Failure to do so may mean that you are not prepared to complete the lab.
-
For this lab, you'll need to sign up with GitHub, a website that hosts software repositories using git (a distributed version control system). With GitHub you'll be able to store, manage and backup your source code. Git is an essential software development tool that you'll want to fully utilize.
Go to https://github.com and sign up if you don't have an account already.
Some other School of Computing (Soc) and university computing resources and policies can be found at the following:
-
Course FAQ: https://github.com/cbourke/ComputerScienceI/blob/master/documents/faq.md
-
SoC Website: http://computing.unl.edu
-
SoC Academic Integrity Policy: http://computing.unl.edu/academic-integrity-policy
-
SoC System Frequently Asked Questions (FAQ): http://computing.unl.edu/faq
-
SoC Undergraduate Advising Page: http://computing.unl.edu/advising
-
SoC Undergraduate Resources: https://computing.unl.edu/current-undergraduate/
For students in online section(s): you may complete the lab on your own if you wish or you may team up with a partner of your choosing.
For students in the on campus section: your lab instructor may team you up with a partner.
To encourage collaboration and a team environment, labs are be structured in a peer programming setup. At the start of each lab, you will be randomly paired up with another student (conflicts such as absences will be dealt with by the lab instructor). One of you will be designated the driver and the other the navigator.
The navigator will be responsible for reading the instructions and telling the driver what to do next. The driver will be in charge of the keyboard and workstation. Both driver and navigator are responsible for suggesting fixes and solutions together. Neither the navigator nor the driver is "in charge." Beyond your immediate pairing, you are encouraged to help and interact and with other pairs in the lab.
Each week you should alternate: if you were a driver last week, be a navigator next, etc. Resolve any issues (you were both drivers last week) within your pair. Ask the lab instructor to resolve issues only when you cannot come to a consensus.
Because of the peer programming setup of labs, it is absolutely essential that you complete any pre-lab activities and familiarize yourself with the handouts prior to coming to lab. Failure to do so will negatively impact your ability to collaborate and work with others which may mean that you will not be able to complete the lab.
At the end of this lab you should be familiar with the following
-
The Visual Studio Code IDE that you'll use for this course
-
Basic unix commands
-
Cloning lab code from Github
-
Modifying, compiling and executing your first C program
-
Submitting and grading your submission
Let's get started. In order to develop programs in C you'll need:
- a code editor (plain text editor) to write your code
- a compiler to compile the C code into executable machine code, and
- a runtime environment to actually execute your program To do this, we'll walk you through how to use the Visual Studio Code (https://cs50.dev/) online IDE (Integrated Development Environment). This is a web browser-based IDE which means you don't have to install any software. It is free and you login using your GitHub account. It also offers a persistent environment: files you save in the IDE will be available next time you login.
- Point your browser to https://cs50.dev/ sign in with GitHub:
Be sure that you have enabled cookies in your browser
- The first time you'll be asked to authorize this site to access elements of your GitHub account, click Authorize cs50.
- Once logged in, it should looks something like the following.
- Observe the major layout areas:
-
File Explorer - This is a graphical file explorer in which you can right click and create new directories (folders) and files, drag and drop to move things around, etc.
-
Text Editor - Double click on a plain text file and it will open in this file editor so you can edit it. This is a tabbed environment so multiple files can be opened at once.
-
Console - this is a Text User Interface (TUI) console in which you can type and execute commands to compile and run (text-based) programs in a Linux (ubuntu) environment.
Let's get started an setup our environment.
-
First, we need to make some directories that we'll be using for the rest of the semester. Execute the following commands by typing each into the TUI console:
mkdir /workspaces/CS1 mkdir /workspaces/CS1/labs mkdir /workspaces/CS1/hacks mkdir /workspaces/CS1/misc
-
Next we'll create a symbolic link so that these directories will appear in the file explorer. Execute the following command:
ln -s /workspaces/CS1 /workspaces/123456/CS1where
123456is replaced with whatever your codespaces number is. -
Every time you start the IDE, your console will start out in a directory named something like
/workspaces/123456, but we'll want to work in theCS1directory where we made our directories. So, let's change directories by executing the following command:cd /workspaces/CS1Note: you will need to change directories every time you login to your IDE. This is necessary because the IDE prevents you from using
gitin the/workspaces/123456directory for "reasons".HOWEVER: there is a semi-permanent solution:
a) create a file in your file explorer and call it
profile, edit it and place the following contents into it:echo "Moving to CS1 folder..." cd /workspaces/CS1b) Copy this (configuration) file by executing the command:
cp profile /home/ubuntu/.profileNow every time you login, the profile configuration will automatically take you to the correct directory in the terminal!
NOTE: if you ever update or "rebuild" your IDE, you will need to recopy this configuration file above to ensure you are in the correct directory.
Using AI does not allow you to learn. As an introductory course our focus will be on learning the basics without the use of AI. Therefore the use of AI chatbots such as ChatGPT or Claude is not allowed. However, filtered AI is an excellent tool for tutoring. Fortunately, there is one built in to the CS50 IDE: the rubber duck debugger. At the left side of the IDE click the duck icon. This will initiate a chat and you can ask it questions! It has been trained to be a tutor that will guide you rather than give you answers. If the duck is not working in the pane, you can go directly to https://cs50.ai/chat
Check Point At this point you should be in your /workspaces/CS1 directory.
Verify this by typing the pwd command that will print your current directory.
If it is not /workspaces/CS1, change your directory appropriately.
You can create files in your IDE either by:
- Dragging and dropping files from your computer to the File Explorer or
- Right clicking a folder and selecting New File
-
Create a file named
info.md(a markdown file) in themiscdirectory and open it for editing by double clicking it. Enter your name in this file (changes are generally automatically saved). -
Now we'll get familiar with the console and some basic unix commands. Click in the console area. To execute a command you type it in the console and then hit enter.
-
Type the command
ls(short for "list") and hit enter. This lists the files and directories in the current working directory. You should see your the three directories we created above. -
Let's change our current working directory so that we're in the
miscdirectory. Type the following commandcd misc(short for "change directory"). Typelsagain and you'll see your the files in yourmiscdirectory (should just be theinfo.mdfile you created). -
You can determine where in the directory structure you are by typing the command
pwd. Try it; you'll see that yourmiscdirectory is actually under a/workspaces/12345678/CS1/miscdirectory -
You can go back "up" the directory structure by typing the command
cd ..(..is short hand for the parent directory or one directory up in the hierarchy) -
You can also remove a file using the
rm fileNamecommand which will permanently delete the file. Careful, there is no undo or recycle bin! You can also remove a file by right clicking and deleting it in the File Explorer.
-
A more comprehensive tutorial on unix commands is available here: http://www.math.utah.edu/lab/unix/unix-commands.html.
Programming requires that you write code in a source file, a plain text file that contains syntactically valid programming commands. In general, you can use any plain text editor to edit code (MS Word is not a plain text editor). However, it is much better to use a text editor designed for code that uses syntax highlighting to help you differentiate various programming elements by highlighting them in different colors and fonts. This IDE provides such an editor. Let's practice writing some code.
-
In your
miscdirectory create a new file namedhello.c -
Open the file and edit its contents to look like the following but with your name and the current date.
/** * Author: Your Name * Date: 20xx/xx/xx * * A simple hello world program in C * */ #include <stdlib.h> #include <stdio.h> int main(int argc, char **argv) { printf("Hello World!\n"); return 0; }
-
Now let's compile this code into an executable program. In the console, type the following command (be sure you're still in the
miscdirectory):gcc hello.cgcc(GNU Compiler Collection) is a C compiler. In general in unix/linux if a command is successful nothing will be displayed; "no news is good news." If you made a mistake the compiler will give you a (sometimes) helpful hint about what was wrong. If you made a mistake fix it and repeat until it successfully compiles. -
When successful, the compiler produces an executable file named
a.out. Uselsto verify that the new file has been created. You should also observe that it has now appeared in the File Explorer. If it has not, you can click the refresh icon to refresh the File Explorer:
- Run your program by typing the following command:
./a.outwhich should printHello World!to the Console.
Congratulations on your first program!
Each lab will have some starter code and other artifacts (data files, scripts, etc.) that will be provided to get you started. The code is hosted on GitHub (https://github.com) and you must clone a copy of it to your own workspace.
-
Change your current working directory to your
labsdirectory. To do this you can usecd ..thencd labs(assuming you are currently inmisc) or you can do this in one step:cd ../labswhich means "go up one directory, then down to
labs." -
To clone, use the the following command:
git clone https://github.com/cbourke/CSCE155-C-Lab01 -
A new directory,
CSCE155-C-Lab01should be created, go into this directory by typingcd CSCE155-C-Lab01 -
List the contents of this directory by typing
ls. If everything worked, there should be a (different)hello.cfile in your directory similar to the one you just wrote.
Boring. Been there done that. So, let's modify the program.
-
Open the
hello.csource file (you now have two files with that name, so be sure you're editing the correct one or close the other). -
Modify the file by changing the author to you (and your partner if you have one) and change the date.
-
Add a new line below the line that prints
Hello World!that printsI love the School of Computing!using theprintfline as an example. -
Save, compile and run your program to make sure it works.
Nearly all of your assignments (labs, hacks, exams) will include a programming portion that will require you to hand in source files for graders to compile and evaluate. To do this, we use Gradescope which is integrated with Canvas.
To handin and grade your lab, do the following.
-
First, we need to get your source file (
hello.c) on to your computer. Right now, the files only exist on the IDE server. Right click on thehello.cfile and click download. -
Login to Canvas and then go to the Assignments tab (direct links are also provided on the front page).
-
Click on the appropriate assignment.
-
You should see something like the following:
- As it says, you can drag and drop multiple files or click the Drag & Drop
button and select file(s). Do so with the
hello.cfile. Then click Upload:
- While upload the grader will run in the background, you can close the popup:
- What for the grader to run fully (this can take up to a minute) and view the results. If everything was successful you should see something like the following:
- If it was not successful, you might see something like this:
In this case, I misspelled School as Skool. That's okay, you can fix
your submission and resubmit as many times as you want up until the due
date. Click the Resubmit button at the bottom right and repeat
the process.
- Partners: for labs and hacks you are allowed to work in pairs if you choose. To ensure your partner gets credit, after you have submitted your final version, click the Group Members button at the bottom of the page.
Then find your partner's name under Add Student and select it and click Add
Some things to understand about the grading process:
- The grades displayed may not be the final grade you earn. Human graders will also assess hacks and exams for other elements.
- Final grades will only post to Canvas after all grading has been completed.
- If there are problems or errors with your program(s), you should fix/debug them and repeat the handin/grading process. You can do this as many times as you like up until the due date.
- Some programs and assignments may require the output to be exact including any upper/lower case text and numbers accurate to a certain number of decimal points.
- Some programs and assignments may only require part of the output to be correct and may ignore other formatting (spaces for example).
- Some programs and assignments may need to be manually examined by graders to award points.
- Some programs and assignments have more sophisticated test suites that run hundreds or thousands of tests.
- In any case, it is your responsibility to read, understand and address any and all errors and/or warnings that the grader produces.
- The grader is a black box tester meaning you don't have access to its internal workings. You should properly and thoroughly test and debug your programs locally instead of relying on it as a "blind tester."
Congratulations on your first lab!











