Recitation R1 - C Programming Tutorial
Fall 2014
CS270: Computer Organization
The purpose of this lab is to learn the basics:
Login to the CS machines
Introduce you to the class website
Create a work area for CS270 programs
Use gedit to write a simple C program
Compile and run your simple C program
Learn how to submit assignments via the checkin tab
See how preliminary testing works
All while getting a start on PA1!
Logging In
Login to the machine, using your eID (Same username that you use for RamCT).
The initial password should be your student ID (or whatever password you currently use).
Troubleshooting:
Raise your hand if you cannot login!
Class Website
Start your preferred internet browser and type in the url
www.cs.colostate.edu/~cs270
.
Look at the syllabus and progress tabs.
Find the recitation instructions for today.
Find the instructions for the first assignment.
Writing a C Program
Browse to the PA1 assignment on the progress page.
Create a directory for CS270 assignments, we recommend ~/cs270.
Create a subdirectory for PA1, we recommend ~/cs270/PA1.
The teaching assistant will explain the sample code provided.
Build and run the sample program.
Modify the sample program to add the computeCircle function.
Modify the sample program to remove the square function.
Implement the call to computeCircle in the main entry point.
Build the PA1 program and test it yourself.
Compiling a C Program
To compile your program into an executable called PA1, type in the following commands to a terminal window:
$ gcc -g -std=c99 -Wall -c PA1.c -o PA1.o $ gcc -g -lm PA1.o -o PA1
To run the compiled program, type the following command:
$ ./PA1
Submitting a C Program
Browse to checkin tab on the course website.
Follow the instructions to login.
Submit the PA1.c file and wait for preliminary testing to complete.
Browse your submitted code and test results.
Show the submitted code and test results to the TA to get credit for the recitation.
Continue working on PA1 as time permits.
© 2014 CS270 Colorado State University. All Rights Reserved.