C++_Basics

C++_Basics - C+ Programming: Basic Elements of C+...

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

View Full Document Right Arrow Icon
C++ Programming: Basic Elements of 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
Introduction Computer program : sequence of statements designed to accomplish some task Programming : planning/creating a program Syntax : rules that specify which statements (instructions) are legal Programming language : a set of rules, symbols, and special words Semantic rule : meaning of the instruction
Background image of page 2
C++ Programs A C++ program is a collection of one or more subprograms, called functions A subprogram or a function is a collection of statements that, when activated (executed), accomplishes something Every C++ program has a function called main The smallest individual unit of a program written in any language is called a token
Background image of page 3

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

View Full DocumentRight Arrow Icon
Symbols Special symbols + - * / . ; ? , <= != == >=
Background image of page 4
Symbols (continued) Word symbols Reserved words, or keywords Include: int float double char void return
Background image of page 5

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

View Full DocumentRight Arrow Icon
Identifiers Consist of letters, digits, and the underscore character ( _ ) Must begin with a letter or underscore C++ is case sensitive Some predefined identifiers are cout and cin Unlike reserved words, predefined identifiers may be redefined, but it is not a good idea
Background image of page 6
Legal and Illegal Identifiers The following are legal identifiers in C++: first conversion payRate
Background image of page 7

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

View Full DocumentRight Arrow Icon
Data Types Data Type : set of values together with a set of operations is called a data type C++ data can be classified into three categories: Simple data type Structured data type Pointers
Background image of page 8
Simple Data Types Three categories of simple data Integral : integers (numbers without a decimal) Floating-point : decimal numbers Enumeration type : user-defined data type
Background image of page 9

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

View Full DocumentRight Arrow Icon
Background image of page 10
int Data Type Examples: -6728 0 78 Positive integers do not have to have a + sign in front of them No commas are used within an integer Commas are used for separating items in a list
Background image of page 11

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

View Full DocumentRight Arrow Icon
bool Data Type bool type Has two values, true and false Manipulate logical (Boolean) expressions true and false are called logical values bool , true , and false are reserved words
Background image of page 12
char Data Type The smallest integral data type Used for characters : letters, digits, and special symbols Each character is enclosed in single quotes Some of the values belonging to char data type are: 'A' , 'a' , '0' , '*' , '+' , '$' , A blank space is a character and is written ' ' , with a space left between the single quotes
Background image of page 13

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

View Full DocumentRight Arrow Icon
C++ uses scientific notation to represent real numbers (floating-point notation) Floating-Point Data Types
Background image of page 14
Floating-Point Data Types (continued) float : represents any real number Range: -3.4E+38 to 3.4E+38 Memory allocated for the float type is 4 bytes double : represents any real number Range: -1.7E+308 to 1.7E+308 Memory allocated for double type is 8 bytes On most newer compilers, data types double and long double are same
Background image of page 15

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

View Full DocumentRight Arrow Icon
Floating-Point Data Types (continued) Maximum number of significant digits
Background image of page 16
Image of page 17
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/14/2011 for the course CSCI 101L taught by Professor Ghyam during the Spring '07 term at USC.

Page1 / 77

C++_Basics - C+ Programming: Basic Elements of C+...

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

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