C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

20
C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang

Transcript of C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

Page 1: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

C Fundamentals

CGS 3460, Lecture 5Jan 20, 2006Hen-I Yang

Page 2: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

Previously… Software Engineering: Implementing a

software that solves real problems. 3 Examples of Problem Analysis. Importance of commenting

Page 3: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

Agenda

Administrivia Brief Explanation of Homework C Fundamentals (Chapter 2). Brief Introduction to UNIX

Page 4: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

Administrivia: Web Site & Syllabus New course web site is now up and running.

The URL remains the same:http://www.cise.ufl.edu/class/cgs3460sp06

A discussion board has been setup with the new web site that allows you ask questions (so I and TAs can answer) or just have discussion with your fellow classmates.

Syllabus has been updated with information with office hours, TA, course web site info, list of course topics, academic dishonesty section, UF counseling service information. Make sure you read the latest version on the web.

Page 5: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

Administrivia: Emails Important Email Address to Remember:

[email protected] to this address for course material related questions. There will be on-duty TA to answer your question every weekday.

Course administrative issues: Email your instructor directly to Hen-I Yang, [email protected]

Of course, you are always welcome to email directly to any of the TAs. But the group mailing list above will give you a better chance for better turn around time.

Remember, always put [CGS3460] in the subject. Clearly indicates [DO NOT POST] to indicate private communication.

Page 6: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

Administrivia: About Next Week I will be out of town to a conference for the entire next

week. All my office hours are cancelled. TA Zhen Yang will be giving tutorials on UNIX,

compilations, and instruction on PC version of the software you can use to implement C programs. Make sure you attend these sessions so you know how to work on your assignments.

Bring a laptop to class for the tutorial sessions if you have one.

Grove accounts will be handed out via email. Read “Use of Computer” section of the syllabus. Turn in your questionnaire to receive your account. Come talk to me after class today if you’re not officially

registered yet.

Page 7: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

Assignment 1

Familiarize yourself with UNIX. Experience the 3-step procedure of edit-

compile-execute. Hands-on exercise on the materials in

chapter 2 of the textbook. Handed out on 1/25, and due 2/7 at

midnight. Zhen Yang will be your main contact for

this first assignment.

Page 8: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

More about Assignments 75% correctness, 25% readability

Correctness is checked via automatic tools. Cheating detection is also checked via automatic tools. Readability is graded by TA manually, and it is possible that only

part of the assignment will be selected for grading on the readability.

Make sure you run on grove before you submit. You should keep a copy of the file, and do not touch it

until you are certain there is no mistake on the test results and the grades.

You have 2 weeks to talk to the TA in charge of that homework after you get the grade of that assignment-quiz set back.

You should use only those instructions taught so far to complete each assignment.

Page 9: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

Assignments: Where to Find Help? Your instructor (me) 3 TAs A total of 20 hours of office hour/week, plus

additional appointments if necessary. Send email to [email protected] for

week-round Q&A. Discussion board and Q&A page on the course

web site. Text book and material posted on the course

web site.

Page 10: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

I believe all of you are honest students, but unfortunately the history of this course has its share of unfortunate instances which seriously put my faith to test. You have my utmost trust and respect, but I strongly urge those who ever come across ideas of employing unfair actions in this class to reconsider. Please do not make me withdraw that trust and respect that you deserve.

I am as serious as it can be when it comes to enforcing the dishonesty rules. Please go back and read the academic honesty section in the syllabus again, and read it carefully this time, as it describes in painful details regarding what are allowed from those forbidden. The Use of computer section also provides information that can help you protect yourself from being taking advantage of. There are serious and grim consequences for academic dishonesty, and I promise you that under no circumstances will I back away from the course of action described in the syllabus.

Page 11: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

We have done everything we could to deter those who plan to cheat, and we will make every reasonable effort to make sure all is fair. Most important of all, you are here to learn. Cheating does not really harm me or TAs, but instead cheaters take advantages of the fellow classmates currently sitting in this very room, and cheaters are cheating oneself out of the opportunity to learn. This, to me, is injustice. This could be one of the least pleasant lectures ever, but in response to the lessons learnt from the previous offerings of this course, this matter has to be placed front and center for once, so there will be no miscommunications or misunderstandings on where the things stand. There is absolutely zero tolerance in this class for any form of dishonest behaviors. I cannot emphasize this enough before we hand out the first homework assignment next week.

I will do my best within my capability to help you learn, and I am sure we’re going to have quite some fun throughout the semester.

Page 12: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

Assignments: Customized questions. Different test cases. Cheating detection programs. Zero dishonesty tolerance.

Strictly follow the standard procedure. First time offender (no priors in ANY COURSE):

FACULTY ADJUDICATION FORM By default

STUDENT JUDICIAL AFFAIRS

Page 13: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

Major components of C Program

Directives Comments Function (main, and others) Declarations Statements

Page 14: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

#include <stdio.h>

/** * First sample program of CGS 3460, spring 2006 * Author: Hen-I Yang * Date: Jan 10, 2006 * Version: 1.0 * Note: * Revision: **/int main(){ /* Declare a variable called name to store name collected */ char *name;

/* Allocate Memory to Record User’s Name Collected */ name = (char *) malloc (25);

/* Collect User’s Name (Name Collect User’s Name) */ puts ("Please enter your name:"); scanf ("%20s", name); /* Print a Greeting Message (Name Screen) */ printf ("Hello, %s\n", name);

return 0;}

directives

comments

declaration

main() function

statement

Page 15: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

Elements of C Programs

Comments (/* */ or //) Directives (include, constants) Global variable declarations Main function Statements Variables

Type Declaration Assignment Initialization

Identifiers

Page 16: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

#include <stdio.h>#define BUFFER_LENGTH 25

int global_count = 0;

/** * First sample program of CGS 3460, spring 2006 * Author: Hen-I Yang * Date: Jan 10, 2006 * Version: 1.0 **/int main(){ /* Declare a variable called name to store name collected */ char *name;

/* Allocate Memory to Record User’s Name Collected */ name = (char *) malloc (BUFFER_LENGTH);

/* Collect User’s Name (Name Collect User’s Name) */ puts ("Please enter your name:"); scanf ("%20s", name);

printName(name);

return 0;}

Void printName(char * name){ /* Print a Greeting Message (Name Screen) */ printf ("Hello, %s\n", name);}

Page 17: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

Coding Conventions

Make them readable Statements can be divided over lines Space between tokens Indentation Blank Lines or remarks between logical

segments Limitations in breaking up token Limitations in breaking up inside the quotation

marks Using // is not a good idea

Page 18: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

3 Ways to Complete Your Programming Assignments

Use Telnet Edited Locally, FTP, Compiled remotely Edited and compiled locally

Page 19: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

Summary

New web site and syllabus available. New and clearer email policy to provide help. Tutorial sessions + Homework 1 assigned next

week. Fundamentals of C.

Components of C Programs Elements of C Programs

Page 20: C Fundamentals CGS 3460, Lecture 5 Jan 20, 2006 Hen-I Yang.

Before you go

Make sure you finish reading Chapter 2. Try logging into grove once you receive ac

count. Contact TA immediately if you still have not received the grove account by email before 11:59 on 1/23.