SlideShare ist ein Scribd-Unternehmen logo
1 von 12
INTRODUCTION TO
C++
INTRODUCTION TO
BY ASIRBACHAN
C++ Character Set
Letters A-Z, a-z
Digits 0-9
Special Characters
Space + -
* / ^  () [] {} = != <> ‘ “ $ , ; :
% ! & ? _ # <= >= @
Formatting characters
backspace, horizontal tab, vertical tab,
form feed, and carriage return
Character set is a set of valid characters that a language can recognize.
Tokens
A token is a group of characters that logically belong together.
The programmer can write a program by using tokens. C++ uses the following types of tokens.
Keywords, Identifiers, Literals, Punctuators, Operators.
SUBJECT VERB OBJECT
#include <iostream>
void main()
cout<< “hello world” ;
{
}
Like a sentence has parts of speeches used in it.
In the same way C++ statements are made of
tokens.
Keywords
These are some reserved words in C++ which have predefined meaning to compiler called keywords.
BOTTLEBAG
Everything in this world has a specific name. You
cannot call it by any other name. This is what exists in
C++ also. There are words in C++ with predefined
meanings and cannot be represented by any other
word.
Identifiers
Symbolic names can be used in C++ for various data items used by a programmer in his program. A
symbolic name is generally known as an identifier. The identifier is a sequence of characters taken from
C++ character set. The rule for the formation of an identifier are:
 An identifier can consist of alphabets, digits and/or underscores.
 It must not start with a digit
 C++ is case sensitive that is upper case and lower case letters are considered different from each
other.
 It should not be a reserved word.
Identifiers are words that deal with memory location.
When we declare a variable it is called as identifier.
Example: 1 int number;
2 cin>> number;
3 cout<< number;
Literals
Literals (often referred to as constants) are data items that never change their value during the
execution of the program. The following types of literals are available in C++.
 Integer-Constants
 Character-constants
 Floating-constants
 Strings-constants
 Bool-constants
‘a’
“Manoeuvre”
67
-5.09
NOTE: The literals are fixed. They do not change values like variables.
1 or 0
Integer Constants
Integer constants are whole number without any fractional part. C++ allows three types of integer
constants.
Decimal integer constants : It consists of sequence of digits and should not begin with 0 (zero). For
example 124, - 179, +108.
Octal integer constants: It consists of sequence of digits starting with 0 (zero). For example. 014,
012.
Hexadecimal integer constant: It consists of sequence of digits preceded by ox or OX.
Character constants
A character constant in C++ must contain one or more characters and must be enclosed in single
quotation marks. For example 'A', '9', etc. C++ allows nongraphic characters which cannot be typed
directly from keyboard, e.g., backspace, tab, carriage return etc. These characters can be
represented by using an escape sequence. An escape sequence represents a single character.
Floating constants
They are also called real constants. They are numbers having fractional parts. They may be written
in fractional form or exponent form. A real constant in fractional form consists of signed or unsigned
digits including a decimal point between digits. For example 3.0, -17.0, -0.627 etc.
String Literals
A sequence of character enclosed within double quotes is called a string literal. String literal is by
default (automatically) added with a special character ‘0' which denotes the end of the string.
Therefore the size of the string is increased by one character. For example "COMPUTER" will re
represented as "COMPUTER0" in the memory and its size is 9 characters.
BoolLiterals
The bool literal is used to represent one of the two Boolean values ie. 1 for true and 0 for false.
Brackets [ ]
Opening and closing brackets indicate single and
multidimensional array subscript.
Parentheses ( )
Opening and closing brackets indicate functions
calls,; function parameters for grouping
expressions etc.
Braces { }
Opening and closing braces indicate the start and
end of a compound statement.
Comma ,
It is used as a separator in a function argument
list.
Semicolon ; It is used as a statement terminator.
Colon :
It indicates a labeled statement or conditional
operator symbol.
Asterisk *
It is used in pointer declaration or as
multiplication operator.
Equal sign = It is used as an assignment operator.
Pound sign # It is used as pre-processor directive.
{Punctuators}; The following characters are used as punctuators in C++.
Operators are special symbols used for specific purposes. C++ provides six types of
operators. Mainly they are classified into Unary and binary operators. Subdivisions:
Arithmetical operators, Relational operators, Logical operators, Unary operators, Assignment
operators, Conditional operators, Comma operator
Operators
+ - * / %
>> == << >= <=
Unary Operators
Unary operators are those that require one operator to operate upon.
Binary Operators
Binary operators are those operators that require two operands to operate
& * + - ~ ++ -- !
+ - * / %
Arithmetic operators
Address
Operator
Indirection
Operator
Unary
Plus
Unary
Minus
Bitwise
Complement
Increment
Operator
Decrement
Operator
Logical
Negation
Add Subtract Multiply Divide Remainder
<< >>
Shift operators
Shift Left Shift Right
&& ||
Logical operators
Logical AND Logical OR
< > <= >= == !=
Relational operators
Less than Equal toGreater than Less than = Greater than = Not equal to

Weitere ähnliche Inhalte

Was ist angesagt?

02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysisraosir123
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++K Durga Prasad
 
Fundamentals of c programming
Fundamentals of c programmingFundamentals of c programming
Fundamentals of c programmingChitrank Dixit
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdfSowmyaJyothi3
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C ProgrammingQazi Shahzad Ali
 
CSharp Language Overview Part 1
CSharp Language Overview Part 1CSharp Language Overview Part 1
CSharp Language Overview Part 1Hossein Zahed
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiSowmyaJyothi3
 
Lecture 13 intermediate code generation 2.pptx
Lecture 13 intermediate code generation 2.pptxLecture 13 intermediate code generation 2.pptx
Lecture 13 intermediate code generation 2.pptxIffat Anjum
 
Diploma ii cfpc u-2 datatypes and variables in c language
Diploma ii  cfpc u-2 datatypes and variables in c languageDiploma ii  cfpc u-2 datatypes and variables in c language
Diploma ii cfpc u-2 datatypes and variables in c languageRai University
 
Bsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageBsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageRai University
 
Tokens expressionsin C++
Tokens expressionsin C++Tokens expressionsin C++
Tokens expressionsin C++HalaiHansaika
 

Was ist angesagt? (20)

02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysis
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
C tokens
C tokensC tokens
C tokens
 
Fundamentals of c programming
Fundamentals of c programmingFundamentals of c programming
Fundamentals of c programming
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
 
Unit ii ppt
Unit ii pptUnit ii ppt
Unit ii ppt
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
CSharp Language Overview Part 1
CSharp Language Overview Part 1CSharp Language Overview Part 1
CSharp Language Overview Part 1
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya Jyothi
 
c++
 c++  c++
c++
 
Lecture 13 intermediate code generation 2.pptx
Lecture 13 intermediate code generation 2.pptxLecture 13 intermediate code generation 2.pptx
Lecture 13 intermediate code generation 2.pptx
 
C language basics
C language basicsC language basics
C language basics
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Diploma ii cfpc u-2 datatypes and variables in c language
Diploma ii  cfpc u-2 datatypes and variables in c languageDiploma ii  cfpc u-2 datatypes and variables in c language
Diploma ii cfpc u-2 datatypes and variables in c language
 
LISP: Input And Output
LISP: Input And OutputLISP: Input And Output
LISP: Input And Output
 
Bsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageBsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c language
 
Tokens expressionsin C++
Tokens expressionsin C++Tokens expressionsin C++
Tokens expressionsin C++
 
BASIC C++ PROGRAMMING
BASIC C++ PROGRAMMINGBASIC C++ PROGRAMMING
BASIC C++ PROGRAMMING
 

Ähnlich wie INTRODUCTION TO C

Object Oriented Programming with C++
Object Oriented Programming with C++Object Oriented Programming with C++
Object Oriented Programming with C++Rokonuzzaman Rony
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c languageRai University
 
Mca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageMca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageRai University
 
Btech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageBtech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageRai University
 
INTRODUCTION TO C++.pptx
INTRODUCTION TO C++.pptxINTRODUCTION TO C++.pptx
INTRODUCTION TO C++.pptxMamataAnilgod
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorialMohit Saini
 
2 expressions (ppt-2) in C++
2 expressions (ppt-2) in C++2 expressions (ppt-2) in C++
2 expressions (ppt-2) in C++Kuntal Bhowmick
 
Fundamentals of C Programming Language
Fundamentals of C Programming LanguageFundamentals of C Programming Language
Fundamentals of C Programming LanguageRamaBoya2
 
PROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptxPROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptxNithya K
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C ProgrammingMOHAMAD NOH AHMAD
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 FocJAYA
 
Basic Programming of c++
Basic Programming of c++Basic Programming of c++
Basic Programming of c++MMAbdullah17
 

Ähnlich wie INTRODUCTION TO C (20)

C++
C++C++
C++
 
C tokens.pptx
C tokens.pptxC tokens.pptx
C tokens.pptx
 
1 Revision Tour
1 Revision Tour1 Revision Tour
1 Revision Tour
 
Object Oriented Programming with C++
Object Oriented Programming with C++Object Oriented Programming with C++
Object Oriented Programming with C++
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c language
 
Ch02
Ch02Ch02
Ch02
 
Mca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageMca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c language
 
Btech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageBtech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c language
 
C Token’s
C Token’sC Token’s
C Token’s
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
INTRODUCTION TO C++.pptx
INTRODUCTION TO C++.pptxINTRODUCTION TO C++.pptx
INTRODUCTION TO C++.pptx
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorial
 
2 expressions (ppt-2) in C++
2 expressions (ppt-2) in C++2 expressions (ppt-2) in C++
2 expressions (ppt-2) in C++
 
Basics of c
Basics of cBasics of c
Basics of c
 
Fundamentals of C Programming Language
Fundamentals of C Programming LanguageFundamentals of C Programming Language
Fundamentals of C Programming Language
 
PROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptxPROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptx
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
Basic Programming of c++
Basic Programming of c++Basic Programming of c++
Basic Programming of c++
 
C Slides
C SlidesC Slides
C Slides
 

Kürzlich hochgeladen

Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEaurabinda banchhor
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxJanEmmanBrigoli
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxRosabel UA
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 

Kürzlich hochgeladen (20)

Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSE
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptx
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 

INTRODUCTION TO C

  • 2. C++ Character Set Letters A-Z, a-z Digits 0-9 Special Characters Space + - * / ^ () [] {} = != <> ‘ “ $ , ; : % ! & ? _ # <= >= @ Formatting characters backspace, horizontal tab, vertical tab, form feed, and carriage return Character set is a set of valid characters that a language can recognize.
  • 3. Tokens A token is a group of characters that logically belong together. The programmer can write a program by using tokens. C++ uses the following types of tokens. Keywords, Identifiers, Literals, Punctuators, Operators. SUBJECT VERB OBJECT #include <iostream> void main() cout<< “hello world” ; { } Like a sentence has parts of speeches used in it. In the same way C++ statements are made of tokens.
  • 4. Keywords These are some reserved words in C++ which have predefined meaning to compiler called keywords. BOTTLEBAG Everything in this world has a specific name. You cannot call it by any other name. This is what exists in C++ also. There are words in C++ with predefined meanings and cannot be represented by any other word.
  • 5. Identifiers Symbolic names can be used in C++ for various data items used by a programmer in his program. A symbolic name is generally known as an identifier. The identifier is a sequence of characters taken from C++ character set. The rule for the formation of an identifier are:  An identifier can consist of alphabets, digits and/or underscores.  It must not start with a digit  C++ is case sensitive that is upper case and lower case letters are considered different from each other.  It should not be a reserved word. Identifiers are words that deal with memory location. When we declare a variable it is called as identifier. Example: 1 int number; 2 cin>> number; 3 cout<< number;
  • 6. Literals Literals (often referred to as constants) are data items that never change their value during the execution of the program. The following types of literals are available in C++.  Integer-Constants  Character-constants  Floating-constants  Strings-constants  Bool-constants ‘a’ “Manoeuvre” 67 -5.09 NOTE: The literals are fixed. They do not change values like variables. 1 or 0
  • 7. Integer Constants Integer constants are whole number without any fractional part. C++ allows three types of integer constants. Decimal integer constants : It consists of sequence of digits and should not begin with 0 (zero). For example 124, - 179, +108. Octal integer constants: It consists of sequence of digits starting with 0 (zero). For example. 014, 012. Hexadecimal integer constant: It consists of sequence of digits preceded by ox or OX. Character constants A character constant in C++ must contain one or more characters and must be enclosed in single quotation marks. For example 'A', '9', etc. C++ allows nongraphic characters which cannot be typed directly from keyboard, e.g., backspace, tab, carriage return etc. These characters can be represented by using an escape sequence. An escape sequence represents a single character.
  • 8. Floating constants They are also called real constants. They are numbers having fractional parts. They may be written in fractional form or exponent form. A real constant in fractional form consists of signed or unsigned digits including a decimal point between digits. For example 3.0, -17.0, -0.627 etc. String Literals A sequence of character enclosed within double quotes is called a string literal. String literal is by default (automatically) added with a special character ‘0' which denotes the end of the string. Therefore the size of the string is increased by one character. For example "COMPUTER" will re represented as "COMPUTER0" in the memory and its size is 9 characters. BoolLiterals The bool literal is used to represent one of the two Boolean values ie. 1 for true and 0 for false.
  • 9. Brackets [ ] Opening and closing brackets indicate single and multidimensional array subscript. Parentheses ( ) Opening and closing brackets indicate functions calls,; function parameters for grouping expressions etc. Braces { } Opening and closing braces indicate the start and end of a compound statement. Comma , It is used as a separator in a function argument list. Semicolon ; It is used as a statement terminator. Colon : It indicates a labeled statement or conditional operator symbol. Asterisk * It is used in pointer declaration or as multiplication operator. Equal sign = It is used as an assignment operator. Pound sign # It is used as pre-processor directive. {Punctuators}; The following characters are used as punctuators in C++.
  • 10. Operators are special symbols used for specific purposes. C++ provides six types of operators. Mainly they are classified into Unary and binary operators. Subdivisions: Arithmetical operators, Relational operators, Logical operators, Unary operators, Assignment operators, Conditional operators, Comma operator Operators + - * / % >> == << >= <=
  • 11. Unary Operators Unary operators are those that require one operator to operate upon. Binary Operators Binary operators are those operators that require two operands to operate & * + - ~ ++ -- ! + - * / % Arithmetic operators Address Operator Indirection Operator Unary Plus Unary Minus Bitwise Complement Increment Operator Decrement Operator Logical Negation Add Subtract Multiply Divide Remainder
  • 12. << >> Shift operators Shift Left Shift Right && || Logical operators Logical AND Logical OR < > <= >= == != Relational operators Less than Equal toGreater than Less than = Greater than = Not equal to