Start Lecture #1
I start at 0 so that when we get to chapter 1, the numbering will agree with the text.
There is a web site for the course. You can find it from my home page, which is http://cs.nyu.edu/~gottlieb
The course has two texts
Replyto contribute to the current thread, but NOT to start another topic.
top post, that is, when replying, I ask that you either place your reply after the original text or interspersed with it.
musttop post.
Grades are based on the labs, midterm, and the final exam, with each
very important.
The weighting will be approximately
30%*LabAverage + 30%*MidtermExam + 40%*FinalExam>
(but see homeworks below).
I use the upper left board for lab/homework assignments and announcements. I should never erase that board. Viewed as a file it is group readable (the group is those in the room), appendable by just me, and (re-)writable by no one. If you see me start to erase an announcement, let me know.
I try very hard to remember to write all announcements on the upper left board and I am normally successful. If, during class, you see that I have forgotten to record something, please let me know. HOWEVER, if I forgot and no one reminds me, the assignment has still been given.
I make a distinction between homeworks and labs.
Labs are
Homeworks are
Homeworks are numbered by the class in which they are assigned. So any homework given today is homework #1. Even if I do not give homework today, the homework assigned next class will be homework #2. Unless I explicitly state otherwise, all homeworks assignments can be found in the class notes. So the homework present in the notes for lecture #n is homework #n (even if I inadvertently forgot to write it to the upper left board).
You may solve lab assignments on any system you wish, but ...
request receiptfeature from home.nyu.edu or mail.nyu.edu and select the
when deliveredoption.
I sent it ... I never received itdebate. Thank you.
Good methods for obtaining help include
Each lab will indicate the language that must be used.
Incomplete
The rules for incompletes and grade changes are set by the school>
and not the department or individual faculty member.>
The rules set by CAS can be found in
The grade of I (Incomplete) is a temporary grade that
indicates that the student has, for good reason, not
completed all of the course work but that there is the
possibility that the student will eventually pass the
course when all of the requirements have been completed.
A student must ask the instructor for a grade of I,
present documented evidence of illness or the equivalent,
and clarify the remaining course requirements with the
instructor.
The incomplete grade is not awarded automatically. It is
not used when there is no possibility that the student
will eventually pass the course. If the course work is
not completed after the statutory time for making up
incompletes has elapsed, the temporary grade of I shall
become an F and will be computed in the student's grade
point average.
All work missed in the fall term must be made up by the end of the
following spring term.
All work missed in the spring term or in a summer session must be
made up by the end of the following fall term.
Students who are out
of attendance in the semester following the one in which the course
was taken have one year to complete the work.
Students should contact the College Advising Center for an Extension
of Incomplete Form, which must be approved by the
instructor.
Extensions of these time limits are rarely granted.
Once a final (i.e., non-incomplete) grade has been submitted by the
instructor and recorded on the transcript, the final grade cannot be
changed by turning in additional course work.
This email from the assistant director, describes the policy.
0.9 Academic Integrity Policy
Dear faculty,
The vast majority of our students comply with the
department's academic integrity policies; see
www.cs.nyu.edu/web/Academic/Undergrad/academic_integrity.html
www.cs.nyu.edu/web/Academic/Graduate/academic_integrity.html
Unfortunately, every semester we discover incidents in
which students copy programming assignments from those of
other students, making minor modifications so that the
submitted programs are extremely similar but not identical.
To help in identifying inappropriate similarities, we
suggest that you and your TAs consider using Moss, a
system that automatically determines similarities between
programs in several languages, including C, C++, and Java.
For more information about Moss, see:
http://theory.stanford.edu/~aiken/moss/
Feel free to tell your students in advance that you will be
using this software or any other system. And please emphasize,
preferably in class, the importance of academic integrity.
Rosemary Amico
Assistant Director, Computer Science
Courant Institute of Mathematical Sciences
Remark: The chapter/section numbers for the material on C, agree with Kernighan and Plauger. However, the material is quite standard so, as mentioned before, if you already own a C book that you like, it should be fine.
Since Java includes much of C, my treatment can be very brief for the parts in common (e.g., control structures).
#include <stdio.h> main() { printf("Hello, world\n"); }
#include <stdio.h> main() { int F, C; int lo=0, hi=300, incr=20; for (F=lo; F<=hi; F+=incr) { C = 5 * (F-32) / 9; printf("%d\t%d\n", F, C); } }
right amountof space (i.e., leaves one blank.
#include <stdio.h> #define LO 0 #define HI 300 #define INCR 20 main() { int F; for (F=LO; F<=HI; F+=INCR) { printf("%3d\t%5.1f\n", F, (F-32)*(5.0/9.0)); } }
The simplest (i.e., most primitive form of character I/O is getchar() and putchar(), which read and print a single character.
File copy is conceptually trivial: getchar() a char and then putchar() the char until eof. The code is on the right and does require some comment despite is brevity.
#include <stdio.h> main() { int c; while ((c = getchar()) != EOF) putchar(c); }
extraparens, which are definitely not extra.
Homework: Write a (C-language) program to print the value of EOF. (This is 1-7 in the book but I realize not everyone will have the book so I will type them in.)
Homework: (1-9) Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank.
The Unix wc program prints the number of characters, words, and lines in the input. It is clear what the number of characters means. The number of lines is the number of newlines (so if the last line doesn't end in a newline, it doesn't count). The number of words is less clear. In particular, what should be the word separators?
#include <stdio.h> #define WITHIN 1 #define OUTSIDE 0 main() { int c, num_lines, num_words, num_chars, within_or_outside; within_or_outside = OUTSIDE; /* C doesn't have Boolean type */ num_lines = num_words = num_chars = 0; while ((c = getchar()) != EOF) { ++num_chars; if (c == '\n') ++num_lines; if (c == ' ' || c == '\n' || c == '\t') within_or_outside = OUTSIDE; else if (within_or_outside == OUTSIDE) { /* at beginning word */ ++num_words; within_or_outside = WITHIN; } } printf("%d %d %d\n", num_lines, num_words, num_chars); }
Homework: (1-12) Write a program that prints its input one word per line.