SlideShare a Scribd company logo
Programming language: It is an artificial language
designed to communicate to a machine, particularly
a computer.
Programs: These are set of instructions written in
any programming language to serve some purpose &
are written by following the syntax of the
programming language.
C++: It was developed in 1980s at Bell Laboratory by
Bjarn Stroustrup as an Object Oriented Programming
Language.
OOP Programming: This approach views a problem in
terms of objects involved rather than procedure for
doing it.
Character set: A set of valid characters that a
language can recognize.
Letters: A to Z, a-z.
Digits: 0 to 9
Special Symbols: Space + - * / ^  ( ) { } [ ] = < > ,
‘ “ $ . ; : % ! & ? _(Underscore) # <= >= @
White Spaces: Blank Space, Horizontal Tab (à),
Carriage return(J), Newline, Form Feed
Other Characters: C++ can process any of the
256 ASCII characters as data or as literals
Tokens: The smallest unit of a program. They are
a. Keywords
b. Identifier
c. Literals(constants)
d. Operators
e. Punctuators
Keywords : they are reserved words meant for
specific purpose. They can not be used for giving
names to variables, arrays, functions etc.
For e.g, If , if else , int , float , case, switch
Identifiers: a name given to program elements such
as variables, arrays, functions etc.
Rule for giving a name to variable :
1. It must start with an alphabet or a character(_).
2. It cannot contain any other character other
than (_) but can contain numbers only after first
character.
Literals : (Often referred to as constants) are data
items that never change their values during a
program run.
Operators: Operators are tokens that trigger some
computation when applied to variables and other
object in an expression. They are
I/o : << and >>
Arithmetic : +, - , * , / , %
Increment/Decrement : ++ , - -
Relational : ==, <, >, <=, >=, !=
Logical : &&, ||, !
Conditional : ?
Punctuators : Also known as separators. They
enhance a program’s readability. For eg
[ ] , { } , ( ) , ; , : , * , = , #
A graphic outline of a simplistic approach to show how programs
get developed.
Define the problem to be solvedSTEP1::
Design a solutionSTEP2::
Write a program that implements the solutionSTEP3::
Compile the programSTEP4::
Link object filesSTEP5::
Test & Debug programSTEP6::
/*Program to display area & perimeter of rectangle*/
#include<iostream.h>
void main()
{
int L,B,A,P;
L=6;
cout<<“Enter Length”<<endl;
cin>>L;
cout<<“Enter Breadth”<<endl;
cin>>B;
A=L*B;
P=2*(L+B);
cout<<“Area is ”<<A<<endl;
cout<<“Perimeter is ”<<P<<endl;
}
Preprocessor Directives
Comments
Function Declarator
Variable Declaration
Variable Initialisation
Displaying text on screen
Assigning entered value to L
Formula
Displaying result
Function Begin
Function ends
To save a file: F2
To run a program: Ctrl+F9
To view the output screen: Alt+F5
To exit from the TC++ editor: Alt+x
To exit from DOS prompt: Type exit
Next you have a summary of the basic fundamental data types in C++, as
well as the range of values that can be represented with each one:
Name Description Size Range*
char
Character or small
integer.
1
signed: -128 to 127
unsigned: 0 to 255
int Integer. 4
signed: -2147483648 to 2147483647
unsigned: 0 to 4294967295
long int
(long)
Long integer. 4
signed: -2147483648 to 2147483647
unsigned: 0 to 4294967295
float
Floating point
number.
4 +/- 3.4e +/- 38 (~7 digits)
Comments: are statements which are not compiled & are
used for programmer’s reference to describe the purpose of
statements or block of statements. It can be done by using
single line comment(//) and multi line comment(/*…..*/).
Header files: files that are included in C++ program to
incorporate the use of functions as required. for e.g.,
iostream.h : cin & cout are used to input value through
keyboard & display the message on display device.
Data Types: are the means to identify the type of data &
associated operations of handling it. They are of two types:
fundamental & derived data types.
Fundamental data types are:
char (stores single character) , int ( stores whole numbers) &
float/double (stores real numbers). declaration of
variable(syntax) :
data_type variable_name;
INPUT AND OUTPUT
cout (to be read as “SEE OUT”): Output Operator(<<) also
called insertion operator. It is used to direct a value to
standard output generally a Monitor.
cin (to be read as “SEE IN”): input operator(>>) also known as
extraction operator. It is used to read a value from standard
input generally a Keyboard.
//PROGRAM TO CALCULATE AREA OF TRIANGLE
#include<iostream.h>
#include<math.h>
void main ( )
{
float S1 ,S2 ,S3, S, area, perimeter;
cout<<“Enter sides of the triangle”<<endl;
cin>>S1>>S2>>S3;
S=(S1+S2+S3)/2.0;
area=sqrt(S*(S-S1)*(S-S2)*(S-S3));
perimeter=S1+S2+S3;
cout<<“Area=“<<Area;
cout<<“ Perimeter=“<<Perimeter;
}
Write a program to :
1. Calculate area & circumference of circle
2. Calculate Sum & Product of two numbers and display them.
3. Input a number in Meters and convert it in Centimeters
4. Calculate the square and cube of a number input by the user
// Area & Circumference of circle
#include<iostream.h>
#include<conio.h>
void main ( )
{
clrscr();
float pi=3.14 ,r , area, cir;
cout<<“Enter radius : ”<<endl;
cin>>r;
area=pi*r*r;
cir=2*pi*r;
cout<<“Area=“<<area;
cout<<“circumference=“<<cir;
getch();
}
//Sum & Product of 2 Numbers
#include<iostream.h>
#include<conio.h>
void main ( )
{
clrscr();
float a, b, sum, pr;
cout<<“Enter a and b: ”<<endl;
cin>>a>>b;
sum=a+b;
pr=a*b;
cout<<“sum=“<<sum;
cout<<“product =“<<pr;
getch();
}
// Input a number in Meters and convert it in Centimeters
#include<iostream.h>
#include<conio.h>
void main ( )
{
clrscr();
float num, cm;
cout<<“Enter a number in meters : ”<<endl;
cin>>num;
cm = num*100;
cout<<“The Entered number is”<<cm << “centimeters”;
getch();
}
To Find Errors in a C++ Program
/* A program to add two numbers
#include<iosteam.h>
void main ( );
{
clrscr();
int a, b, sum;
cout<<“Enter Value for a”<<endl;
cin>>A;
cout<<“Enter Value for b”;
cin>>b;
Sum=a+b;
cout<<“ Sum is =“<<sum
}
Errors are:
Comment not terminated / closed
Spelling of iosteam.h
‘ ; ’ not to used at the end of main
Header (conio.h) is not included
Variable is ‘a’ and not ‘A’
Variable is ‘sum’ and not ‘Sum’
End of Statement should be ‘ ; ’
PRACTICE QUESTIONS
Write a program to Convert the following:
1. Meter to Kilometer (1 Km = 1000 Meter)
2. Centigrade to Fahrenheit (F = C*(9/5)+32)
3. Feet into Meters(1 Meter = 3.28 Feet)
4. Hours into Minutes, Seconds (1 Hr = 60 Min = 3600 Sec)
ACTIVITY QUESTIONS 9A( Oct 13)
Write a program to
Get temperature in Centigrade to Fahrenheit
(F = C*9/5+32)
OR
Input three values from the user. Add & multiply them and
then display the output
Save it with your roll no and class. For Eg: 9A424
ACTIVITY QUESTIONS 9B( Oct 13)
Write a program to
Get temperature in Centigrade to Fahrenheit
(F = C*9/5+32)
OR
Input three values from the user. Add & multiply them and
then display the output
Save it with your roll no and class. For Eg: 9B255
ACTIVITY QUESTIONS 9C( Oct 13)
Write a program to
Get length in feet and then convert it into meters
(1 Meter = 3.28 Feet)
OR
Input two values from the user. Add & multiply them and
then display the output
Save it with your roll no and class. For Eg: 9A245
ACTIVITY QUESTIONS 9D( Oct 13)
Write a program to
Get length in feet and then convert it into meters
(1 Meter = 3.28 Feet)
OR
Input two values from the user. Add & multiply them and
then display the output
Save it with your roll no and class. For Eg: 9A245
ACTIVITY QUESTIONS 9E( Oct 13)
Write a program to
Get temperature in Centigrade to Fahrenheit
(F = C*9/5+32)
OR
Input three values from the user. Add & multiply them and
then display the output
Save it with your roll no and class. For Eg: 9B255

More Related Content

What's hot

Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generation
Dr.DHANALAKSHMI SENTHILKUMAR
 
T03 b basicioscanf
T03 b basicioscanfT03 b basicioscanf
T03 b basicioscanf
teach4uin
 
C programming Lab 1
C programming Lab 1C programming Lab 1
C programming Lab 1
Zaibi Gondal
 
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)
Tasif Tanzim
 
CS291(C Programming) assignment
CS291(C Programming) assignmentCS291(C Programming) assignment
CS291(C Programming) assignment
Kuntal Bhowmick
 
Ecs40 winter 2017 homework 3
Ecs40 winter 2017 homework 3Ecs40 winter 2017 homework 3
Ecs40 winter 2017 homework 3
JenniferBall44
 
Intermediate code
Intermediate codeIntermediate code
Intermediate code
Vishal Agarwal
 
Unit 5 structure and unions
Unit 5 structure and unionsUnit 5 structure and unions
Unit 5 structure and unions
kirthika jeyenth
 
COMPILER DESIGN AND CONSTRUCTION
COMPILER DESIGN AND CONSTRUCTIONCOMPILER DESIGN AND CONSTRUCTION
COMPILER DESIGN AND CONSTRUCTION
Anil Pokhrel
 
Xi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programsXi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programs
Prof. Dr. K. Adisesha
 
3. user input and some basic problem
3. user input and some basic problem3. user input and some basic problem
3. user input and some basic problem
Alamgir Hossain
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
YOGESH SINGH
 
Three Address code
Three Address code Three Address code
Three Address code
Pooja Dixit
 
Compiler Design Lab File
Compiler Design Lab FileCompiler Design Lab File
Compiler Design Lab File
Kandarp Tiwari
 
Assignment9
Assignment9Assignment9
Assignment9
Sunita Milind Dol
 
2. introduction of a c program
2. introduction of a c program2. introduction of a c program
2. introduction of a c program
Alamgir Hossain
 

What's hot (20)

Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generation
 
T03 b basicioscanf
T03 b basicioscanfT03 b basicioscanf
T03 b basicioscanf
 
ICP - Lecture 6
ICP - Lecture 6ICP - Lecture 6
ICP - Lecture 6
 
C programming Lab 1
C programming Lab 1C programming Lab 1
C programming Lab 1
 
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)
 
CS291(C Programming) assignment
CS291(C Programming) assignmentCS291(C Programming) assignment
CS291(C Programming) assignment
 
Ecs40 winter 2017 homework 3
Ecs40 winter 2017 homework 3Ecs40 winter 2017 homework 3
Ecs40 winter 2017 homework 3
 
Intermediate code
Intermediate codeIntermediate code
Intermediate code
 
Unit 5 structure and unions
Unit 5 structure and unionsUnit 5 structure and unions
Unit 5 structure and unions
 
COMPILER DESIGN AND CONSTRUCTION
COMPILER DESIGN AND CONSTRUCTIONCOMPILER DESIGN AND CONSTRUCTION
COMPILER DESIGN AND CONSTRUCTION
 
Xi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programsXi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programs
 
Strings and pointers
Strings and pointersStrings and pointers
Strings and pointers
 
3. user input and some basic problem
3. user input and some basic problem3. user input and some basic problem
3. user input and some basic problem
 
Basic Input and Output
Basic Input and OutputBasic Input and Output
Basic Input and Output
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
 
Three Address code
Three Address code Three Address code
Three Address code
 
Lab 1
Lab 1Lab 1
Lab 1
 
Compiler Design Lab File
Compiler Design Lab FileCompiler Design Lab File
Compiler Design Lab File
 
Assignment9
Assignment9Assignment9
Assignment9
 
2. introduction of a c program
2. introduction of a c program2. introduction of a c program
2. introduction of a c program
 

Similar to C++

C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
Vikram Nandini
 
C material
C materialC material
C material
tarique472
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to cHattori Sidek
 
C programming language
C programming languageC programming language
C programming language
Abin Rimal
 
Introduction to C Unit 1
Introduction to C Unit 1Introduction to C Unit 1
Introduction to C Unit 1
SURBHI SAROHA
 
c++ referesher 1.pdf
c++ referesher 1.pdfc++ referesher 1.pdf
c++ referesher 1.pdf
AnkurSingh656748
 
C programming
C programmingC programming
C programming
Shahariar limon
 
PRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptxPRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptx
SajalKesharwani2
 
Lecture 01 2017
Lecture 01 2017Lecture 01 2017
Lecture 01 2017
Jesmin Akhter
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteaching
eteaching
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
KabilaArun
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
DrGSakthiGovindaraju
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
attalurilalitha
 
C programming session 01
C programming session 01C programming session 01
C programming session 01Dushmanta Nath
 
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
ANUSUYA S
 
introductory concepts
introductory conceptsintroductory concepts
introductory conceptsWalepak Ubi
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
20EUEE018DEEPAKM
 

Similar to C++ (20)

Chap 2 c++
Chap 2 c++Chap 2 c++
Chap 2 c++
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
 
C material
C materialC material
C material
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
 
C notes
C notesC notes
C notes
 
C programming language
C programming languageC programming language
C programming language
 
Introduction to C Unit 1
Introduction to C Unit 1Introduction to C Unit 1
Introduction to C Unit 1
 
c++ referesher 1.pdf
c++ referesher 1.pdfc++ referesher 1.pdf
c++ referesher 1.pdf
 
C programming
C programmingC programming
C programming
 
PRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptxPRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptx
 
Lecture 01 2017
Lecture 01 2017Lecture 01 2017
Lecture 01 2017
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteaching
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
 
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
 
C tutorials
C tutorialsC tutorials
C tutorials
 
introductory concepts
introductory conceptsintroductory concepts
introductory concepts
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
 

Recently uploaded

How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 

Recently uploaded (20)

How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 

C++

  • 1.
  • 2. Programming language: It is an artificial language designed to communicate to a machine, particularly a computer. Programs: These are set of instructions written in any programming language to serve some purpose & are written by following the syntax of the programming language. C++: It was developed in 1980s at Bell Laboratory by Bjarn Stroustrup as an Object Oriented Programming Language. OOP Programming: This approach views a problem in terms of objects involved rather than procedure for doing it.
  • 3. Character set: A set of valid characters that a language can recognize. Letters: A to Z, a-z. Digits: 0 to 9 Special Symbols: Space + - * / ^ ( ) { } [ ] = < > , ‘ “ $ . ; : % ! & ? _(Underscore) # <= >= @ White Spaces: Blank Space, Horizontal Tab (à), Carriage return(J), Newline, Form Feed Other Characters: C++ can process any of the 256 ASCII characters as data or as literals
  • 4. Tokens: The smallest unit of a program. They are a. Keywords b. Identifier c. Literals(constants) d. Operators e. Punctuators Keywords : they are reserved words meant for specific purpose. They can not be used for giving names to variables, arrays, functions etc. For e.g, If , if else , int , float , case, switch Identifiers: a name given to program elements such as variables, arrays, functions etc. Rule for giving a name to variable : 1. It must start with an alphabet or a character(_). 2. It cannot contain any other character other than (_) but can contain numbers only after first character.
  • 5. Literals : (Often referred to as constants) are data items that never change their values during a program run. Operators: Operators are tokens that trigger some computation when applied to variables and other object in an expression. They are I/o : << and >> Arithmetic : +, - , * , / , % Increment/Decrement : ++ , - - Relational : ==, <, >, <=, >=, != Logical : &&, ||, ! Conditional : ? Punctuators : Also known as separators. They enhance a program’s readability. For eg [ ] , { } , ( ) , ; , : , * , = , #
  • 6.
  • 7. A graphic outline of a simplistic approach to show how programs get developed. Define the problem to be solvedSTEP1:: Design a solutionSTEP2:: Write a program that implements the solutionSTEP3:: Compile the programSTEP4:: Link object filesSTEP5:: Test & Debug programSTEP6::
  • 8. /*Program to display area & perimeter of rectangle*/ #include<iostream.h> void main() { int L,B,A,P; L=6; cout<<“Enter Length”<<endl; cin>>L; cout<<“Enter Breadth”<<endl; cin>>B; A=L*B; P=2*(L+B); cout<<“Area is ”<<A<<endl; cout<<“Perimeter is ”<<P<<endl; } Preprocessor Directives Comments Function Declarator Variable Declaration Variable Initialisation Displaying text on screen Assigning entered value to L Formula Displaying result Function Begin Function ends
  • 9. To save a file: F2 To run a program: Ctrl+F9 To view the output screen: Alt+F5 To exit from the TC++ editor: Alt+x To exit from DOS prompt: Type exit
  • 10. Next you have a summary of the basic fundamental data types in C++, as well as the range of values that can be represented with each one: Name Description Size Range* char Character or small integer. 1 signed: -128 to 127 unsigned: 0 to 255 int Integer. 4 signed: -2147483648 to 2147483647 unsigned: 0 to 4294967295 long int (long) Long integer. 4 signed: -2147483648 to 2147483647 unsigned: 0 to 4294967295 float Floating point number. 4 +/- 3.4e +/- 38 (~7 digits)
  • 11. Comments: are statements which are not compiled & are used for programmer’s reference to describe the purpose of statements or block of statements. It can be done by using single line comment(//) and multi line comment(/*…..*/). Header files: files that are included in C++ program to incorporate the use of functions as required. for e.g., iostream.h : cin & cout are used to input value through keyboard & display the message on display device. Data Types: are the means to identify the type of data & associated operations of handling it. They are of two types: fundamental & derived data types. Fundamental data types are: char (stores single character) , int ( stores whole numbers) & float/double (stores real numbers). declaration of variable(syntax) : data_type variable_name;
  • 12. INPUT AND OUTPUT cout (to be read as “SEE OUT”): Output Operator(<<) also called insertion operator. It is used to direct a value to standard output generally a Monitor. cin (to be read as “SEE IN”): input operator(>>) also known as extraction operator. It is used to read a value from standard input generally a Keyboard. //PROGRAM TO CALCULATE AREA OF TRIANGLE #include<iostream.h> #include<math.h> void main ( ) { float S1 ,S2 ,S3, S, area, perimeter; cout<<“Enter sides of the triangle”<<endl; cin>>S1>>S2>>S3; S=(S1+S2+S3)/2.0; area=sqrt(S*(S-S1)*(S-S2)*(S-S3)); perimeter=S1+S2+S3; cout<<“Area=“<<Area; cout<<“ Perimeter=“<<Perimeter; }
  • 13. Write a program to : 1. Calculate area & circumference of circle 2. Calculate Sum & Product of two numbers and display them. 3. Input a number in Meters and convert it in Centimeters 4. Calculate the square and cube of a number input by the user // Area & Circumference of circle #include<iostream.h> #include<conio.h> void main ( ) { clrscr(); float pi=3.14 ,r , area, cir; cout<<“Enter radius : ”<<endl; cin>>r; area=pi*r*r; cir=2*pi*r; cout<<“Area=“<<area; cout<<“circumference=“<<cir; getch(); } //Sum & Product of 2 Numbers #include<iostream.h> #include<conio.h> void main ( ) { clrscr(); float a, b, sum, pr; cout<<“Enter a and b: ”<<endl; cin>>a>>b; sum=a+b; pr=a*b; cout<<“sum=“<<sum; cout<<“product =“<<pr; getch(); }
  • 14. // Input a number in Meters and convert it in Centimeters #include<iostream.h> #include<conio.h> void main ( ) { clrscr(); float num, cm; cout<<“Enter a number in meters : ”<<endl; cin>>num; cm = num*100; cout<<“The Entered number is”<<cm << “centimeters”; getch(); }
  • 15. To Find Errors in a C++ Program /* A program to add two numbers #include<iosteam.h> void main ( ); { clrscr(); int a, b, sum; cout<<“Enter Value for a”<<endl; cin>>A; cout<<“Enter Value for b”; cin>>b; Sum=a+b; cout<<“ Sum is =“<<sum } Errors are: Comment not terminated / closed Spelling of iosteam.h ‘ ; ’ not to used at the end of main Header (conio.h) is not included Variable is ‘a’ and not ‘A’ Variable is ‘sum’ and not ‘Sum’ End of Statement should be ‘ ; ’
  • 16. PRACTICE QUESTIONS Write a program to Convert the following: 1. Meter to Kilometer (1 Km = 1000 Meter) 2. Centigrade to Fahrenheit (F = C*(9/5)+32) 3. Feet into Meters(1 Meter = 3.28 Feet) 4. Hours into Minutes, Seconds (1 Hr = 60 Min = 3600 Sec)
  • 17. ACTIVITY QUESTIONS 9A( Oct 13) Write a program to Get temperature in Centigrade to Fahrenheit (F = C*9/5+32) OR Input three values from the user. Add & multiply them and then display the output Save it with your roll no and class. For Eg: 9A424
  • 18. ACTIVITY QUESTIONS 9B( Oct 13) Write a program to Get temperature in Centigrade to Fahrenheit (F = C*9/5+32) OR Input three values from the user. Add & multiply them and then display the output Save it with your roll no and class. For Eg: 9B255
  • 19. ACTIVITY QUESTIONS 9C( Oct 13) Write a program to Get length in feet and then convert it into meters (1 Meter = 3.28 Feet) OR Input two values from the user. Add & multiply them and then display the output Save it with your roll no and class. For Eg: 9A245
  • 20. ACTIVITY QUESTIONS 9D( Oct 13) Write a program to Get length in feet and then convert it into meters (1 Meter = 3.28 Feet) OR Input two values from the user. Add & multiply them and then display the output Save it with your roll no and class. For Eg: 9A245
  • 21. ACTIVITY QUESTIONS 9E( Oct 13) Write a program to Get temperature in Centigrade to Fahrenheit (F = C*9/5+32) OR Input three values from the user. Add & multiply them and then display the output Save it with your roll no and class. For Eg: 9B255