01_intro - CSCI-1200 Data Structures — Fall 2010 Lecture...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSCI-1200 Data Structures — Fall 2010 Lecture 1 — Introduction and Background Instructor Professor Barb Cutler 331A Materials Research Center (MRC), x3274 [email protected] Today • Discussion of Website & Syllabus: http://www.cs.rpi.edu/academics/courses/fall10/ds/ – Instructor, TAs, & office hours – Course overview & emphasis – Prerequisites, expectations, & grading – Calendar – Textbooks, lecture notes, ALAC drop-in tutoring, & web resources – Homework: Electronic Submission & Late Policy – Academic Integrity • Quick Review/Overview of C/C++ Programming: – the main function – iostreams & the standard library – C++ vs. Java – variables, constants, operators, expressions, and statements – if-else conditional – arrays – for & while loops – functions and parameter passing – scope – algorithm analysis / order notation 1.1 Example 1: Hello World Here is the standard introductory program. We use it to illustrate a number of important points. // a small C++ program #include <iostream> int main() { std::cout << "Hello, world!" << std::endl; return 0; } 1.2 Basic Syntax • Comments are indicated using // for single line comments and /* and */ for multi-line comments. • #include asks the compiler for parts of the standard library and other code that we wish to use (e.g. the input/output stream function std::cout ). • int main() is a necessary component of all C++ programs; it returns a value (integer in this case) and it may have parameters. • { } : the curly braces indicate to C++ to treat everything between them as a unit. 1.3 The Standard Library • The standard library is not a part of the core C++ language. Instead it contains types and functions that are important extensions. We will use the standard library to such a great extent that it will feel like part of the C++ core language. • streams are the first component of the standard library that we see. • std is a namespace that contains the standard library. • std::cout and std::endl are defined in the standard library (in particular, in the standard library header file iostream ). 1.4 Expressions • Each expression has a value and 0 or more side effects . Side effects include: printing to the screen, writing to a file, changing the value of a variable, or crashing the computer. • An expression followed by a semi-colon is a statement . The semi-colon tells the computer to “throw away” the value of the expression. (Hopefully we first saved it to a variable if we wanted to keep it around!) • This line is really two expressions and one statement: std::cout << "Hello, world!" << std::endl; • "Hello, world!" is a string literal . 1.5 C++ vs. Java The following is provided as additional material for students who have learned Java and are now learning C++....
View Full Document

This note was uploaded on 02/21/2012 for the course CSCI 1200 taught by Professor Cutler during the Fall '08 term at Rensselaer Polytechnic Institute.

Page1 / 11

01_intro - CSCI-1200 Data Structures — Fall 2010 Lecture...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online