1 / 43

Fundamentals of Computer Science

Fundamentals of Computer Science. Ethan Cerami New York University Spring 2000. Today. Course Description Or, what am I getting myself into? Exams, Grades, Course Web Page, etc. The Lego Theory and the Course Syllabus What’s a Programming Language? Why Learn C? “Hello, World!” Program

Download Presentation

Fundamentals of Computer Science

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Fundamentals of Computer Science Ethan Cerami New York University Spring 2000

  2. Today • Course Description • Or, what am I getting myself into? • Exams, Grades, Course Web Page, etc. • The Lego Theory and the Course Syllabus • What’s a Programming Language? • Why Learn C? • “Hello, World!” Program • Your first taste of real programming.

  3. How do I get these slides? • Occasionally, I will use present PowerPoint slides. • Whenever I do so, I will post them to the course web page: • Go to http://cs.nyu.edu • Click on Course Home Pages • Click on V22.0380.002 Course Home Page

  4. Why is this class so *%&#*@#! Early? • Yes, class starts at 8:00 am. • Last semester, class started at 8:30 am. This semester, NYU gets cruel ;) • Please try and stay awake! • We will usually have a break at around 8:45. So, go get coffee.

  5. Course Description • Official Description: This is a course in computer programming concepts for students with little or no programming experience. The intent is to teach students to write both clear and efficient C programs by emphasizing structured programming principles. This course is intended as a first course for information systems majors, for students of other scientific disciplines, and for a functional introduction to programming.

  6. What the class is really about There are four main goals of this course: 1. Basics of C 2. Core Concepts of Programming Languages 3. Basics of Software Development 4. Extra Topics

  7. 1. Learn the Basics of C Programming • C is a popular programming language, widely used in Industry. • We will learn all the specifics of how to program in C. • This includes all the peculiar rules that are specific to C. • We will cover all the fundamentals: Variables, For Loops, While Loops, Arrays, Pointers, Structures, etc.

  8. For Example /* Sample C Program */ #include <stdio.h> #define MAX_NUM 10 main () { int i; for (i=0; i<MAX_NUM; i++) { printf ("Number: %d\n", i); } return 0; } This program counts from 1 to 10. In a few weeks, it will all make sense.

  9. 2. Learn the Core Concepts of all Programming Languages • There are lots of programming languages available: Pascal, Java, Ada, Lisp, Perl. • All of these languages share core concepts. • By focussing on these concepts, you are better able to learn any programming language. • Hence, by learning C, you are poised to learn other languages, such as C++ or Java. • By learning the core concepts, you are also much more marketable as you are able to learn new technologies much faster.

  10. For Example: For Loops • C has a construct called a for loop that enables a program to repeat actions over and over. • Every other language also has a for loop. • Hence, by learning about for loops in C, you can easily learn for loops in C++ or Java.

  11. 3. Learn the Principles of Software Development • Building high quality software is very difficult. • The course therefore presents the syntax and concepts of programming, but also presents strategies for building real software that addresses real problems. • I will also try to bring real-world industry experience to class.

  12. For Example: Principle 61: “Transition from specification to code is not easy.”* Specification for building an Airline Reservation System Actual Software that gets the job done. * Alan M. Davis, “201 Principles of Software Development”, (McGraw Hill, Inc, 1995.)

  13. 4. Extra Topics “Try to imagine all the new kinds of computers that will arrive in the next generation or two. Imagine what we -- actually our children and grandchildren -- will do with them all. One thing is sure: whatever wild visions you can conjure are too tame.” -- Peter J. Denning, “Beyond Calculation: The Next Fifty Years of Computing” (ACM: 1997.)

  14. Extra Topics in the Past • DigiScents: computers capable of producing smells (!) • TCP/IP: understanding how the Internet routes packets to the correct destination. • Virtual Reality and 3D Chat • Computer Animation • The technology behind Burger King’s Whopper.

  15. On to Administrative Issues... • Books • Software • Grades • Getting Help • Course Home Page

  16. Required Text Book Deitel and Deitel, C: How to Program Very comprehensive text book. Available at the NYU Book Store.

  17. Supplemental Book Kernighan and Ritche, The C Programming Language -- Written by the creators of C. -- A good reference, but not an easy read.

  18. Annotated Programs Packet • Word Document that contains all the programs to be discussed in class. • Available on the Course Web Site. • Some are taken from the book, some were created in previous semesters. • You can also download all the programs directly from the web site, and try them out within your own compiler. • Please bring the packet to every class!

  19. Software • We will use the Borland C++ compiler. • Borland C++ is available in some Stern Labs and all the ACF Labs. • You can also purchase an academic version for ~$50 from the NYU Computer Bookstore. • If you buy a copy, you want to buy Borland C++ Builder 4.0, and install the CD named, “Borland C++, Version 5.0” (you won’t need the other CDs for this class.)

  20. Other things you will need • Email Account: All homework assignments must be submitted via E-Mail. • Floppy Disks: If you are planning on using the NYU Computer Labs, make sure to save your programs to a floppy disk.

  21. Grading • All homework must be done individually. The Grader will be checking for cheating. • Also, see the late policy on our web site. • How your grade is determined: • homework: 40% • midterm exam: 25% • final exam 35%

  22. Getting Help Many students find this course very challenging. When you get stuck, ask for help! 1. Office Hours: Every Thursday, 9:30 am - 11:30 am, 419 Warren Weaver Hall. 2. E-Tutor: E-Tutor is required to write back in 24 hours. (See Web Page for E-Tutor’s Email Address.) 3. Yahoo! Club: Write your questions here, and other students might be able to help out.

  23. Course Home Page • Everything regarding the course is available via the Course Home Page. So, check it early and often. • How to get to the Home Page: • Go to http://cs.nyu.edu • Click on Course Home Pages • Click on V22.0380.002 Course Home Page

  24. The Lego Theory The Lego Theory: Complex software is built with simple, basic building blocks. Check out: http://www.lego.com/justbuild/buildpage.asp

  25. Lego Theory (cont.) • Lego theory goes by many different names: abstraction, “divide and conquer”, object orientation, etc. • Nonetheless, it represents the most powerful idea in computer science, and the most important thing you will learn this semester. • If nothing else, I hope you remember the Lego theory five years from now.

  26. Lego Theory Applied: Basic Example Suppose you want to print your name five times. Main Lego Block: For Coordinating everything Lego Block: Printf() for displaying your name Lego Block: For loop for repeating actions

  27. Lego Theory Applied: Searching the Web • Suppose you want to build a piece of software that searches the web. Lego Block 1: Retrieves user search keyword and sends the query to Lego Block 2. Once it has results from Lego Block 2, send it to Lego Block 3 Lego Block 3: Formats the results in a nice graphical interface. Lego Block 2: Huge storage of web sites.

  28. Searching the Web (cont.) • By using the Lego Theory, you break complicated tasks into smaller, simpler subtasks. • You can also more easily divide up the work, and more easily figure out where things go wrong.

  29. How we will use the Lego Theory • Each week, we will introduce a new basic building block. For example, this week we will cover input and output. Later on, we will cover variables. • By combining these blocks, we can start creating more and more powerful programs. • By the end of the semester, you will have all the basic blocks for building very sophisticated software.

  30. Syllabus: First Half of Semester • Week 1: Basic Input/Output • Week 2: Variables, Basic Mathematics • Week 3: If/Else, While Loops • Week 4: For Loops, Logical Operators • Week 5-7: Functions

  31. What’s a Programming Language? • Programming Language: A language used to create computer applications. • Examples of Programming Languages: • C • C++ • Pascal • Java (Internet) • Cobol (COmmon Buisiness Oriented Language) • Ada (mainly used by Department of Defense)

  32. Why Learn C? So, why pick C? 1. It’s a very powerful, very fast language. 2. C is one of the most widely used languages. People use it in the ‘real world’ 3. It forms the basis of more advanced languages, such as C++ and Java.

  33. C v. Pascal • Lots of other introductory classes focus on Pascal. • Pascal is easier to program, but it’s only used in Academic settings. And, this course tries to focus on practical business applications. • "Pascal keeps your hand tied. C gives you enough rope to hang yourself."

  34. History of C • Developed in 1972 at Bell Labs (now part of Lucent Technologies) • C does not stand for anything: C evolved from a language called B (which also didn’t stand for anything.)

  35. ANSI C • ANSI C: American National Standards Institute • Standard C that runs on most operating systems. • There are lots of operating systems currently is use: Windows, Macintosh, UNIX, IBM Mainframes. You can run ANSI C on any of these platforms. • Portable: a program that runs on more than one operating system.

  36. Your first C Program /* First Program in C */ #include <stdio.h> main() { printf("Hello, World!"); /* Wait for user to Press Enter */ getchar(); } Hello, World!

  37. Comments /* First Program in C */ • Text that helps you and others to understand the program • Completely ignored by the computer • Anything between /* and */ • A Program with no comments is a very bad program. Tip: You must include comments in your homeworks.

  38. #include <stdio.h> • #include tells the compiler to include certain library files. • stdio.h stands for Standard Input/Output header file • stdio.h is required any time you use printf or scanf. • Other libraries: math.h, graphics.h

  39. main () function • Every C program must have a main function. • Every program begins execution at the main function. • No matter how big your program, you must always have a main(). • We will return to a formal definition of functions later.

  40. Blocks of Code {} • Any code between { and } is considered a block of code. • In this case, anything between { and } is considered part of the main function. • Hence, when we run main, we will run everything within the {} block.

  41. printf("Hello, World!"); • Displays a string of text. • String: any text appearing within quotes. • Printf is an example of a statement. • Note that all statements in C end with a semi-colon.

  42. /* Wait for user to Press Enter */ getchar(); • getchar() pauses the program until the user presses the ENTER key. • As we will soon see, this pause is important when running programs under Borland C++. • Without the getchar(), the program will run and exit so fast that you will not see any output.

  43. Quick Recap Comments /* First Program in C */ #include <stdio.h> main() { printf("Hello, World!"); /* Wait for user to Press Enter */ getchar(); } #include library main () function printf() Block of Code

More Related