Instructor: Tina Tian
About me Office: RLC 203A Office Hours: Wednesday 1:30 - 4:30 PM or for appointment Website: home.manhattan.edu/~tina.tian/
About the Course Monday, Thursday 1:30 - 2:45 PM RLC 104 Textbook: Gaddis 8 th Edition (preferred) Gaddis 7 th Edition Grading: 1 st Midterm Exam (5 th week)15% 2 nd Midterm Exam (10 th week)15% Final Exam30% Lab Assignments and Homework 40%
Homework Assignments All are programming. Expect homework Each homework may contain several programming problems. Homework is due a week after being announced. No late work is accepted.
Homework Assignments Hard copy electronic copy will not be accepted Source code Screen shot of output/test run
Advices Stay close to the computers and try out the example programs! You can work as a team but don’t copy code. Save your programs home.manhattan.edu s flash drive
About MS Visual Studio Integrated Development Environment (IDE) Used to develop console and graphical user interface (GUI) applications Supports C/C++, C#, VB, etc. Visual Studio 2012 Professional (lab) Visual Studio Express: Community 2015 (Free to download onto personal computers)
If you are using Mac.. Xcode Free Compiler
About C++ High-level language e.g., C++, C, Java, Python, PHP, Visual Basic... Designed to be easy to read and write Low-level language e.g., assembly language ADD X Y Z Assembly language must be translated to machine language (zeros and ones) Any high-level language program must be translated into machine language for the CPU to execute.
Compilers A program that translates a high-level language to a machine language Source code The original program in a high level language Object code The translated version in machine language
Linkers Some programs we use are already compiled Their object code is available for us to use For example: Input and output routines A Linker combines The object code for the programs we write and The object code for the pre-compiled routines into The machine language program the CPU can run
Algorithms Algorithm A sequence of precise instructions that leads to a solution Program An algorithm expressed in a language the computer can understand
Desktop testing: mentally going through the algorithm Testing: running the program on sample input data
Object Oriented Programming (OOP) Used for many modern programs Program is viewed as interacting objects Procedural vs. OOP
Some history of C++ C++ is derived from C. C developed by Dennis Ritchie at AT&T Bell Labs in the 1970s. Used to maintain UNIX systems a high-level language with many of the features of a low-level language Good for writing system programs, but hard to understand C++ developed by Bjarne Stroustrup at AT&T Bell Labs in the 1980s. Overcame several shortcomings of C Incorporated object oriented programming C remains a subset of C++
Include Directives #include Preprocessor directive iostream is a library containing definitions of the input and output function Linker Appears at the start of the program, begin with # using namespace std; Tells the compiler to use names in iostream in a “standard” way
int main() {//beginning of the main function....//statements return 0; }//end of the program
The output function cout c(C++ language)out(output) c(C++ language)in(input) cout<<whatever data you want to output; cout<<“Welcome to CMPT102!”; << represents the flow of the data.
Okay, let’s write a hello world program in C++ C++ is fun!
Note No extra space between #include Old C++ compilers: iostream.h Statements end with a semi-colon.
Program Layout Compiler accepts almost any pattern of line breaks and indentation Programmers format programs so they are easy to read Place opening brace ‘{‘ and closing brace ‘}’ on a line by themselves Indent statements Use only one statement per line
.cpp file.exe file
More about cout <<: insertion operator cout<<“Hello World”; is equivalent to cout<<“Hello”<<“ World”; is equivalent to cout<<“Hello ”; cout<<“World”;
About cout Start a new line \n (need to go inside of the quotes) endl Escape sequence \nnew line \ttab \”“ \\\
Comments // This is a comment. /* This is a comment. This is another comment. */
Exercise Write a simple program to print to the screen the following. Be sure to add your name in the comment. Hello! I say “C++ is fun!” Good-bye!
Readings Chapter 2 Download and install Visual Studio