Unformatted text preview:

CSCI 101 Fundamentals of Computer Programming Lab 2 I O Programming Fall 2005 Grading Scheme 5 10 65 10 10 Information Block Name Email Section etc Program Algorithm Comments Implementation Core Program Compilation Other Key Issues Programming Style Indentation Meaningful Identifiers etc Output Correctness and Format Submission Instructions In the directory containing your source code file you want to submit test1 c for homework 1 A The command used for submission is submit user csci101 tag hw1 test1 c indicates your LAB section number This will be the same for all homework submissions The following message will appear if the submission is successful Submitting file test1 c to csci101 SUCCEEDED B Submitting Multiple files say test1 c test2 c test3 c submit user csci101 tag hw1 test1 c test 2 c test3 c The following message will appear if the submission is successful Submitting file test1 c test2 c test3 c to csci101 SUCCEEDED Once you submit the file you can t get it back But you can always modify the file in your USC account and resubmit it again and again The old file s will be overwritten Esubmission must be done before your lab session at the due date For homework 2 change the tag to hw2 and so on to ensure that your submission is properly graded If you submit with the wrong tag you will be heavily penalized for it Lab Sections 33702 33505 33506 33504 33508 33507 33703 8 00 9 50 Th 10 00 11 50 T 10 00 11 50 F 12 00 1 50 W 3 30 5 20 W 5 00 6 50 W SAL 127 SAL 127 SAL 126 SAL 126 SAL 126 SAL 127 SAL 127 Jenny Shyam Bansal Shyam Bansal Shyam Kale Jenny Kale Jenny Kale 5 00 6 50 Th Bansal Bilal Sample Program For your first program a basic C program will be created using the printf and scanf command Open a C file using emacs filename c In the editor type in the following Name Student ID Program 1 Lab Section Lab Assistant Date This program prompts the user for two integers It also prints out the integers as well as the sum to the screen Header file include stdio h Main Program int main void Local definitions int num1 num2 sum Statements printf Please enter two of your favorite integers here scanf d d num1 num2 sum num1 num2 printf Your favorite integers are d and d n num1 num2 printf The sum of the integers are d n sum return 0 Make sure that the code is well commented and the algorithm is clearly illustrated Save the file and exit emacs If no errors were reported during compilation it has been successfully compiled Run the output file and it should asks you for your favorite integer waits for your input and outputs it again Compiling Compiling a C file is done using the gcc command e g gcc filename This will output an a out file in the same directory Run the file by typing in a out and press enter Another option is by using the o option e g gcc o outputname filename This will output a file with the outputname instead of the a out file Exercise As an exercise create the algorithm and write a program that does the following a Requests for the two sides of a right triangle b Calculates the hypotenuse of the right triangle c Prints out the value in a coherent manner When completed demonstrate it to the lab assistant to get full credit Hint You will need to include the math h header file and compile your program with the following command gcc lm exercise2 c The new option is a lowercase L and it stands for linking You want to link your compiled program with the math library


View Full Document

USC CSCI 101L - lab2a

Documents in this Course
Load more
Download lab2a
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view lab2a and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view lab2a and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?