c++ chapter 1
TRANSCRIPT
C++ LanguageBy : Shrirang PinjarkarEmail : [email protected]
INTRODUCTIONC++ IS A PROGRAMMING LANGUAGEIT IS A HIGHER VERSION OF C LANGUAGEC++ IS A OBJECT ORIENTED LANGUAGEIN EARLY 1980’SAT BELL LABORATORIES, USA.
LANGUAGELanguage is way to communicate with each other
PROGRAMA PROGRAM IS A SET/SEQUENCE OF COMMANDS
COMPUTER LANGUAGE AND MACHINE LANGUAGEBINARY LANGUAGE/MACHINE
LANGUAGE/LOW LEVEL LANGUAGEComputer is an electronic device at its core level it works on Binary Language i.e., 0,1 or high & low. Everything in computer is stored in LLL.HIGH LEVEL LANGUAGEProgramming languages like JAVA,C,C++ are called HLL. Code of all these language are written in English language.
LANGUAGE PROCESSORSCOMPILER-Converts HLL to LLL and vice versa. It converts the whole program in one go and notifies all the errors at the same time
C++ CHARACTER SET Character sets are the characters used to write a language.Characters A-Z, a-z.Digits 0-9.Special Symbols {} [] () ; : “ ‘ < > ? & # ~ | \ / etc.White spaces, new line characters .Besides all these C++ has 256 ASCII characters.
ASCII- American Standard Code for Information Interchange
TOKENS/LEXICAL UNITS When the compiler is processing the source
code of a program, each group of characters separated by white spaces is called a token.
C++ Allows 5 Types Of Tokens1. KEYWORDS2. IDENTIFIERS3. LITERALS/CONSTANTS4. PUNTUATORS/SEPARATORS5. OPERATORS
KEYWORDS KEYWORDS ( also known as specially reserved words) CONVEYS A SPECIAL MEANING TO COMPILER. KEYWORDS are always typed in short(lower) case.They are reserved by the language for special purpose and can not be redefined as an IDENTIFIER.
IDENTIFIERSIDENTIFIERS ARE THE NAMES GIVEN BY THE PROGRAMMER TO DIFFERENT BLOCKS, PARTS OF A PROGRAM TO IDENTIFY THEM.IDENTIFIERS REFER TO THE NAMES OF VARIABLES , FUNCTIONS ,ARRAYS ,CLASSES
,ETC
The C++ language is a "case sensitive" language. That means that an identifier written in capital letters is not equivalent to another one with the same name but written in small letters. Thus, for example, the NUMBER variable is not the same as the result variable or the number variable.
RULES/CONVENTIONS FOR DEFINING IDENTIFIERS
It can contain characters(A-Z, a-z),Digits(0-9), & only one special symbol called underscore(_).First letter must be a character (A-Z, a-z) or underscore(_).No commas or blank spaces allowed.C++ IS A CASE SENSITIVE LANGUAGE i.e., Upper case and Lower case characters are different.
Exercise : Valid or not?
mass Force 2ndBit pos12 speed_of_light yağmur SpeedOfLight float isPrime speed of light
LITERALS/CONSTANTSLITERALS AND CONSTANTS ARE THOSE TOKENS WHOSE VALUES DON’T CHANGE DURING THE PROGRAM EXECUTION.
LITERALS/CONSTANTSINTEGER CONSTANTcomplete rounded off numbers are called integer constants for ex :- 540, 2, 98 etc.REAL/FLOAT CONSTANTSNumbers with decimal point are called Real/Float literals for ex :- 2.5, 0.54, 45.98 etc.CHARACTER CONSTANTSSingle character enclosed within single quotes(‘ ’) are called character constants for ex :- ‘A’, ‘B’, ‘d’ etc.STRING CONSTANTS
Group of characters enclosed within double quotes(“ “) are called string literals for ex :- “programming” “language” etc.
PUNTUATORS/SEPARATORS
PUNTUATORS ARE USED TO SEPARATE TOKENS WITHIN A PROGRAM. THE VARIOUS PUNUATORS ARE:
{} [] () : ; , etc.
OPERATORSOPERATORS OPERATES ON SOME DATA TO GIVE RESULTS
For ex :- A+B=C
Here A, B are operand and + is the operator which produces C as a result of addition of A and B.
OPERATORSVarious operators in C++ are Arithmetic operators
+,-,*,/,%Relational operatorsLogical operatorsIncrement/Decrement OperatorsConditional Operators