Chapter2 - Chapter 2 INTRODUCTION TO C+ A sample C+...

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

View Full Document Right Arrow Icon
Chapter 2 INTRODUCTION TO C++
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 A sample C++ program: hypot.cpp Values Variables side1 3.45 side2 4.26 hypot 5.4818
Background image of page 2
3 C++ PROGRAM STRUCTURE
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 C++ PROGRAM STRUCTURE The main() Function C++ programs must have a main function. This is where program execution begins. For now, code the main function as shown below. int main( void ) { statements return 0; }
Background image of page 4
5 Header Files
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Header Files Header files contain C++ source code that defines functions, objects., etc. You will normally have one or more header files included at the beginning of your program. Use a #include directive at the beginning of your program to attach a header file to your program.
Background image of page 6
7 Header Files Header file names USED TO typically end with “ .h ” – NOT ANYMORE! For example, you will almost always use: #include<iostream> or #include<iomanip> in your programs. Without them, you could not perform basic input and output to the terminal.
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 Header Files Header files ending in .h are deprecated Old style, not correct anymore Conversion table Deprecated header Correct header iostream.h iostream iomanip.h iomanip stdlib.h cstdlib math.h cmath fstream.h fstream
Background image of page 8
9 Header Files When using the correct header styles, after the header files includes you must have using namespace std; Deprecated header Correct header iostream.h iostream iomanip.h iomanip stdlib.h cstdlib math.h cmath fstream.h fstream
Background image of page 9

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

View Full DocumentRight Arrow Icon
10 Header Files Example: #include<iostream> #include<cmath> using namespace std; int main( void ) {. ..} Deprecated header Correct header iostream.h iostream iomanip.h iomanip stdlib.h cstdlib math.h cmath fstream.h fstream
Background image of page 10
11 Statements
Background image of page 11

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

View Full DocumentRight Arrow Icon
12 Statements One statement may span several lines.
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/05/2011 for the course CGS 2421 taught by Professor Onal during the Fall '09 term at University of Florida.

Page1 / 47

Chapter2 - Chapter 2 INTRODUCTION TO C+ A sample C+...

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

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