Saturday, 12 October 2013

C++ Course (Second Section)

C++ Course
Second section (Knowing Some Important Concepts)

The Basics of a C++ Program:

•Function: A collection of statements; when executed, accomplishes something
−May be predefined or standard
•Syntax: Rules that specify which statements (instructions) are legal.
•Programming Language: A set of rules, symbols, and special words.
•Semantic Rule: The meaning of the instruction.
•Comments:
Comments are for the reader, not the compiler.
Two types:
−Single line
// This is a C++ program. It prints the sentence:
// Welcome to C++ Programming.
−Multiple line
/*
You can include comments that can occupy several lines. 
 */
•Special symbols :
+ - * / . ; ? , <= != == >=
Reserved Words (Keywords):
Reserved words, keywords, or word symbols
−Include:
•int
•float
•double
•char
•const
•void
•return

•Identifiers:
•Consists of letters, digits, and the underscore character (_).
•Must begin with a letter or underscore.
•C++ is case sensitive.
−NUMBER is not the same as number.
•Two predefined identifiers are cout and cin.
•Unlike reserved words, predefined identifiers may be redefined, but it is not a good idea.

Data Types:
1) Integers (int)
•Examples:
-6728
0
78
+763
 •Positive integers do not need a + sign
•No commas are used within an integer
−Commas are used for separating items in a list

2) Boolean (bool)
•bool type 
−Two Values: true and false 
−Manipulate Logical (Boolean) expressions 
•true and false are called logical values 
•bool, true, and false are reserved words 


3) Character (char)
•The smallest integral data type 
•Used for characters: letters, digits, and special symbols 
•Each character is enclosed in single quotes 
−'A', 'a', '0', '*', '+', ', '&' 
•A blank space is a character and is written ' ', with a space left between the single quotes


4) Floating-Point (float)
•C++ uses scientific notation to represent real numbers (floating-point notation)
Examples:
3.4
0.00023
-1.567
Types of float:
−Float: represents any real number 
•Range: -3.4E+38 to 3.4E+38 (four bytes) 
−Double: represents any real number 
•Range: -1.7E+308 to 1.7E+308 (eight bytes) 
−On most newer compilers, data types double and long double are same

•Maximum number of significant digits (decimal places) for float values is 6 or 7
•Maximum number of significant digits for double is 15
•Precision: maximum number of significant digits
−Float values are called single precision
−Double values are called double precision

5) String 
•Programmer-defined type supplied in ANSI/ISO Standard C++ library 
•Sequence of zero or more characters 
•Enclosed in double quotation marks 
•Null: a string with no characters 
•Each character has relative position in string 
−Position of first character is 0 
•Length of a string is number of characters in it 
−Example: length of "William Jacob" is 13

Unknown

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

0 comments:

Post a Comment

 
biz.