SlideShare a Scribd company logo
1 of 28
Introduction To C++ Programming
Ali Aminian & Bardia Nezamzadeh
1
Section Outline
โ€ข Workspace
โ€ข Basics of C++ Environment
โ€ข Definition of Types
โ€ข Operations in C++
2
Section Outline
โ€ข Workspace
โ€ข Basics of C++ Environment
โ€ข Definition of Types
โ€ข Operations in C++
3
Workspace
โ€ข One of the most famous workspaces is
โ€œMicrosoft Visual Studioโ€
โ€ข Creating a project :
lets follow these pictures :
4
Workspace(cont.)
5
Section Outline
โ€ข Workspace
โ€ข Basics of C++ Environment
โ€ข Definition of Types
โ€ข Operations in C++
6
โ€ข Comments
-Single-line comment
โ€ข Begin with : // this is comment (Fortran : !)
-Multiple-line comment
โ€ข Begin with : /* โ€ฆ /* this is a multiple line
โ€ข End with : โ€ฆ*/ comment. We still have
this line!*/
โ€ข Preprocessor directives
-Processed by preprocessor before compiling
-Begin with # include <math>
Basics of C++ Environment
7
Adding math library to the project.
โ€ข Different type of files in C++
โ€“ Header files (.h)
โ€“ cpp files (.cpp)
โ€“ Most important headers:
๏‚ง iostream.h
๏‚ง iomanip.h
๏‚ง math.h
๏‚ง cstdlib.h
Basics of C++ Environment(cont.)
Standard input/output
Manipulate stream format
Math library function
Conversion function for
text to number , number to
text, memory allocation,
random numbers and various
other utility functions
8
Basics of C++ Environment(cont.)
โ€ข Program Framework
int main()
{
โ€ฆโ€ฆโ€ฆโ€ฆโ€ฆโ€ฆ..
โ€ฆโ€ฆโ€ฆโ€ฆโ€ฆโ€ฆ..
โ€ฆโ€ฆโ€ฆโ€ฆโ€ฆโ€ฆ..
return 0;
}
(Frotran Framework:)
PROGRAM name
โ€ฆโ€ฆโ€ฆโ€ฆโ€ฆโ€ฆ..
โ€ฆโ€ฆโ€ฆโ€ฆโ€ฆโ€ฆ..
โ€ฆโ€ฆโ€ฆโ€ฆโ€ฆโ€ฆ..
END
9
โ€ข Some important Syntaxes
โ€“ include<>
โ€“ main()
โ€“ cin>> , cout<<
โ€ข These are like READ , PRINT
โ€“ ; (Semicolon)
โ€ข Shows the end of line . (works the same as in Fortran)
Basics of C++ Environment(cont.)
In next slides we introduce the other syntax symbols, these are most
familiar for any program which we could see in any code
10
Basics of C++ Environment(cont.)
Phases of C++ Programs:
1. Edit
2. Preprocess
3. Compile
4. Link
5. Load
6. Execute Loader
Primary
Memory
Program is created in
the editor and stored
on disk.
Preprocessor program
processes the code.
Loader puts program
in memory.
CPU takes each
instruction and
executes it, possibly
storing new data
values as the program
executes.
Compiler
Compiler creates
object code and stores
it on disk.
Linker links the object
code with the libraries,
creates a.out and
stores it on disk
Editor
Preprocessor
Linker
CPU
Primary
Memory
.
.
.
.
.
.
.
.
.
.
.
.
Disk
Disk
Disk
Disk
Disk
11
Basics of C++ Environment(cont.)
1 // Printing multiple lines with a single statement
2 #include <iostream>
3
4 // function main begins program execution
5 int main()
6 {
7 std::cout << "Welcome to C++!n";
8
9 return 0; // indicate that program ended successfully
10
11 } // end function main
Comments
Preprocessor directive to include
input/output stream header file
<iostream>
We include this library to use the
std::cout command for printing.
Function main appears
exactly once in every
C++ program..
Special Characters
We use these characters
to write some characters
that can not be written in
normal way:
n Enter
t Tab
 backslash itself!
Keyword return is
one of several means to
exit function; value 0
indicates program
terminated successfully.
Welcome to C++!
Output:
12
Section Outline
โ€ข Workspace
โ€ข Basics of C++ Environment
โ€ข Definition of Types
โ€ข Operations in C++
13
Definition of Types
โ€ข Floating point variables
โ€“ float : 6 digits after floating point
โ€“ double : 12 digits after floating point (more
precision)
All of above types are useful to store real values such as:
0.12E5 Or 2.3212
14
Definition of Types(cont.)
โ€ข Integer variables
We can use following words to do some alternative
with int type:
โ€“ short โ€“ unsigned int
โ€“ unsigned short โ€“ long
โ€“ int โ€“ unsigned long
These words change range and starting point of
integer variables :
e.g. short int a; //range -32768 to 32767
15
Type Min. range Max. range
short -32768 32767
unsigned short 0 65535
int -2147483648 2147483647
unsigned int 0 4294967295
long -9223372036854775808 9223372036854775807
unsigned long 0 18446744073709551615
Definition of Types(cont.)
16
Definition of Types(cont.)
โ€ข bool
โ€“ This type has just two values: (true, false)
โ€“ Note : in Fortran we use LOGICAL and .true. And .false.
combination Instead.
โ€ข char
โ€“ This type is used to store ASCII characters
โ€“ e.g. char a =โ€˜Qโ€™;
โ€ข enum
โ€“ It creates a list, in witch every elements has a number
and we can use the elements instead of numbers
(notice to example in next slide)
17
Definition of Types(cont.)
E.G. :
If we define such an enum :
enum Day{SAT,SUN,MON,TUE,WED,THU,FRI}
Now if we define a variable from Day type then
this variable can accept the values that define
Inside the Day type such as SAT, SUN, MON,โ€ฆ
e.g. Day mybirthday = MON;
18
Definition of Types(cont.)
NOTES:
๏ƒผvariable precision:
1.2 / 2 returns integer or double?
๏ƒผCasting:
e.g. : a = (int) c; //a is int and c is double (c was 12.63)
If we didnโ€™t use cast in this example, C++ would
store 12 inside a.
19
Definition of Types(cont.)
โ€ข We can have our own types with typedef keyword.
e.g. typedef long double real;
real a; //a is a long double variable now
20
Exactly the same type in C++Type in Fortran
shortINTEGER *2
intINTEGER *4
long intINTEGER *8
floatREAL*4
doubleREAL*8
long doubleREAL*16
charCHARACTER
boolLOGICAL
Basics of C++ Environment(cont.)
โ€ข MORE NOTES!
๏ƒผ we use const command to define constant
variables ( Fortran : PARAMETER )
e.g. const int a = 12;
๏ƒผ there is no need to write & when we want to
write multiple line commands
๏ƒผ C++ is a case sensitive language ( vs. Fortran )
21
Section Outline
โ€ข Workspace
โ€ข Basics of C++ Environment
โ€ข Definition of Types
โ€ข Operations in C++
22
Operations in C++
โ€ข Conditional operands
other operands : < , <= , => , >
23
FortranC++
.AND.&&And
.OR.||Or
.NEQV.!=Not equivalent
.EQV.==Equivalent
Operations in C++
โ€ข If (condition) {statement }
โ€ข If , else
if (a==true)
{
b=b+1;
}
else
{
b=b-1;
}
It is important that how compiler ,
compile these operations
24
Operations in C++
โ€ข for(init;condition;command) {statement}
for(i=0; i<10; i++)
{
b--; // b=b-1
}
variable i will advance from 0 itself to 9 itself
during the loop
25
Operations in C++
โ€ข while(condition) {statement}
while(a)//if a is true
{
b++; // b=b+1
if(b==100)
{
break;
}
}
๏ฑ notes :
๏ƒ˜break: breaks the loop and steps out
๏ƒ˜Ctrl+C: manually breaking the loop!
26
Operations in C++(cont.)
โ€ข Variable++ / ++Variable
x=y++ is different from x=++y
โ€ข > , < , => , != , == (Comparisons operand) , =
โ€ข ||, && (Logical operand)
โ€ข condition ? expression1 : expression2
โ€“ if(condition) {expression1 } else {expression2}
โ€ข goto : label
you must know what want to do
exactly otherwise this is very dangerous !
27
In future :
i. Pointers and related argues
ii. Functions
iii.Class and related concepts
iv.ERRORS
28

More Related Content

What's hot

C++ PROGRAMMING BASICS
C++ PROGRAMMING BASICSC++ PROGRAMMING BASICS
C++ PROGRAMMING BASICSAami Kakakhel
ย 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming LanguageSteve Johnson
ย 
(2) cpp imperative programming
(2) cpp imperative programming(2) cpp imperative programming
(2) cpp imperative programmingNico Ludwig
ย 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cppNilesh Dalvi
ย 
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 eteachingeteaching
ย 
Lecture01
Lecture01Lecture01
Lecture01Xafran
ย 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++Himanshu Kaushik
ย 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overviewTAlha MAlik
ย 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language Mohamed Loey
ย 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++Sangharsh agarwal
ย 
Intro to C++ - language
Intro to C++ - languageIntro to C++ - language
Intro to C++ - languageJussi Pohjolainen
ย 
Overview of c++ language
Overview of c++ language   Overview of c++ language
Overview of c++ language samt7
ย 

What's hot (20)

Introduction to C++
Introduction to C++Introduction to C++
Introduction to C++
ย 
C++ PROGRAMMING BASICS
C++ PROGRAMMING BASICSC++ PROGRAMMING BASICS
C++ PROGRAMMING BASICS
ย 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
ย 
C++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWAREC++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWARE
ย 
(2) cpp imperative programming
(2) cpp imperative programming(2) cpp imperative programming
(2) cpp imperative programming
ย 
C++
C++C++
C++
ย 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
ย 
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
ย 
c++
 c++  c++
c++
ย 
Lecture01
Lecture01Lecture01
Lecture01
ย 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
ย 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
ย 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
ย 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
ย 
Intro to C++ - language
Intro to C++ - languageIntro to C++ - language
Intro to C++ - language
ย 
The smartpath information systems c plus plus
The smartpath information systems  c plus plusThe smartpath information systems  c plus plus
The smartpath information systems c plus plus
ย 
C++ Language
C++ LanguageC++ Language
C++ Language
ย 
C++ for beginners
C++ for beginnersC++ for beginners
C++ for beginners
ย 
Overview of c++ language
Overview of c++ language   Overview of c++ language
Overview of c++ language
ย 
Basics of c++
Basics of c++Basics of c++
Basics of c++
ย 

Viewers also liked

Multi-touch Interface for Controlling Multiple Mobile Robots
Multi-touch Interface for Controlling Multiple Mobile RobotsMulti-touch Interface for Controlling Multiple Mobile Robots
Multi-touch Interface for Controlling Multiple Mobile RobotsJun Kato
ย 
Chapter 14
Chapter 14Chapter 14
Chapter 14Terry Yoast
ย 
Vc++ 3
Vc++ 3Vc++ 3
Vc++ 3Raman Rv
ย 
1. c or c++ programming course out line
1. c or c++ programming course out line1. c or c++ programming course out line
1. c or c++ programming course out lineChhom Karath
ย 
Handling Exceptions In C &amp; C++[Part A]
Handling Exceptions In C &amp; C++[Part A]Handling Exceptions In C &amp; C++[Part A]
Handling Exceptions In C &amp; C++[Part A]ppd1961
ย 
Operation engine ii session iv operations scheduling
Operation engine  ii session iv  operations schedulingOperation engine  ii session iv  operations scheduling
Operation engine ii session iv operations schedulingFatima Aliza
ย 
Chapter 1 - An Introduction to Programming
Chapter 1 - An Introduction to ProgrammingChapter 1 - An Introduction to Programming
Chapter 1 - An Introduction to Programmingmshellman
ย 
2 the visible pc
2 the visible pc2 the visible pc
2 the visible pchafizhanif86
ย 
SDL Vision for Digital Experience - Arjen van den Akker at SDL Connect 16
SDL Vision for Digital Experience - Arjen van den Akker at SDL Connect 16SDL Vision for Digital Experience - Arjen van den Akker at SDL Connect 16
SDL Vision for Digital Experience - Arjen van den Akker at SDL Connect 16SDL
ย 
Data com chapter 1 introduction
Data com chapter 1   introductionData com chapter 1   introduction
Data com chapter 1 introductionAbdul-Hamid Donde
ย 
Active x control
Active x controlActive x control
Active x controlAmandeep Kaur
ย 
Sdi & mdi
Sdi & mdiSdi & mdi
Sdi & mdiBABAVALI S
ย 
ICTCoreCh11
ICTCoreCh11ICTCoreCh11
ICTCoreCh11garcons0
ย 
Bitmap and Vector Images: Make Sure You Know the Differences
Bitmap and Vector Images: Make Sure You Know the DifferencesBitmap and Vector Images: Make Sure You Know the Differences
Bitmap and Vector Images: Make Sure You Know the DifferencesDavina and Caroline
ย 
11. Computer Systems Hardware 1
11. Computer Systems   Hardware 111. Computer Systems   Hardware 1
11. Computer Systems Hardware 1New Era University
ย 
VC++ Fundamentals
VC++ FundamentalsVC++ Fundamentals
VC++ Fundamentalsranigiyer
ย 
Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)Peter R. Egli
ย 

Viewers also liked (20)

Multi-touch Interface for Controlling Multiple Mobile Robots
Multi-touch Interface for Controlling Multiple Mobile RobotsMulti-touch Interface for Controlling Multiple Mobile Robots
Multi-touch Interface for Controlling Multiple Mobile Robots
ย 
Giรกo trรฌnh lแบญp trรฌnh GDI+
Giรกo trรฌnh lแบญp trรฌnh GDI+Giรกo trรฌnh lแบญp trรฌnh GDI+
Giรกo trรฌnh lแบญp trรฌnh GDI+
ย 
Chapter 14
Chapter 14Chapter 14
Chapter 14
ย 
Vc++ 3
Vc++ 3Vc++ 3
Vc++ 3
ย 
1. c or c++ programming course out line
1. c or c++ programming course out line1. c or c++ programming course out line
1. c or c++ programming course out line
ย 
Handling Exceptions In C &amp; C++[Part A]
Handling Exceptions In C &amp; C++[Part A]Handling Exceptions In C &amp; C++[Part A]
Handling Exceptions In C &amp; C++[Part A]
ย 
Operation engine ii session iv operations scheduling
Operation engine  ii session iv  operations schedulingOperation engine  ii session iv  operations scheduling
Operation engine ii session iv operations scheduling
ย 
Chapter 1 - An Introduction to Programming
Chapter 1 - An Introduction to ProgrammingChapter 1 - An Introduction to Programming
Chapter 1 - An Introduction to Programming
ย 
COM
COMCOM
COM
ย 
2 the visible pc
2 the visible pc2 the visible pc
2 the visible pc
ย 
SDL Vision for Digital Experience - Arjen van den Akker at SDL Connect 16
SDL Vision for Digital Experience - Arjen van den Akker at SDL Connect 16SDL Vision for Digital Experience - Arjen van den Akker at SDL Connect 16
SDL Vision for Digital Experience - Arjen van den Akker at SDL Connect 16
ย 
Data com chapter 1 introduction
Data com chapter 1   introductionData com chapter 1   introduction
Data com chapter 1 introduction
ย 
Active x control
Active x controlActive x control
Active x control
ย 
Sdi & mdi
Sdi & mdiSdi & mdi
Sdi & mdi
ย 
ICTCoreCh11
ICTCoreCh11ICTCoreCh11
ICTCoreCh11
ย 
Bitmap and Vector Images: Make Sure You Know the Differences
Bitmap and Vector Images: Make Sure You Know the DifferencesBitmap and Vector Images: Make Sure You Know the Differences
Bitmap and Vector Images: Make Sure You Know the Differences
ย 
11. Computer Systems Hardware 1
11. Computer Systems   Hardware 111. Computer Systems   Hardware 1
11. Computer Systems Hardware 1
ย 
VC++ Fundamentals
VC++ FundamentalsVC++ Fundamentals
VC++ Fundamentals
ย 
a+ ptc
a+ ptca+ ptc
a+ ptc
ย 
Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)
ย 

Similar to Learning C++ - Introduction to c++ programming 1

POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
ย 
(8) cpp abstractions separated_compilation_and_binding_part_i
(8) cpp abstractions separated_compilation_and_binding_part_i(8) cpp abstractions separated_compilation_and_binding_part_i
(8) cpp abstractions separated_compilation_and_binding_part_iNico Ludwig
ย 
College1
College1College1
College1Sudharsan S
ย 
c programming L-1.pdf43333333544444444444444444444
c programming L-1.pdf43333333544444444444444444444c programming L-1.pdf43333333544444444444444444444
c programming L-1.pdf43333333544444444444444444444PurvaShyama
ย 
Programming in C [Module One]
Programming in C [Module One]Programming in C [Module One]
Programming in C [Module One]Abhishek Sinha
ย 
Fp201 unit2 1
Fp201 unit2 1Fp201 unit2 1
Fp201 unit2 1rohassanie
ย 
#Code2 create c++ for beginners
#Code2 create  c++ for beginners #Code2 create  c++ for beginners
#Code2 create c++ for beginners GDGKuwaitGoogleDevel
ย 
(2) cpp imperative programming
(2) cpp imperative programming(2) cpp imperative programming
(2) cpp imperative programmingNico Ludwig
ย 
C++ Constructs.pptx
C++ Constructs.pptxC++ Constructs.pptx
C++ Constructs.pptxLakshyaChauhan21
ย 
Csdfsadf
CsdfsadfCsdfsadf
CsdfsadfAtul Setu
ย 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C ProgrammingQazi Shahzad Ali
ย 
C_plus_plus
C_plus_plusC_plus_plus
C_plus_plusRalph Weber
ย 
Presentation 5th
Presentation 5thPresentation 5th
Presentation 5thConnex
ย 
C tutorials
C tutorialsC tutorials
C tutorialsAmit Kapoor
ย 
Lecture 1.pptx
Lecture 1.pptxLecture 1.pptx
Lecture 1.pptxMark82418
ย 
C++ L01-Variables
C++ L01-VariablesC++ L01-Variables
C++ L01-VariablesMohammad Shaker
ย 
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...Cyber Security Alliance
ย 

Similar to Learning C++ - Introduction to c++ programming 1 (20)

POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
ย 
(8) cpp abstractions separated_compilation_and_binding_part_i
(8) cpp abstractions separated_compilation_and_binding_part_i(8) cpp abstractions separated_compilation_and_binding_part_i
(8) cpp abstractions separated_compilation_and_binding_part_i
ย 
Chap 2 c++
Chap 2 c++Chap 2 c++
Chap 2 c++
ย 
College1
College1College1
College1
ย 
c programming L-1.pdf43333333544444444444444444444
c programming L-1.pdf43333333544444444444444444444c programming L-1.pdf43333333544444444444444444444
c programming L-1.pdf43333333544444444444444444444
ย 
Programming in C [Module One]
Programming in C [Module One]Programming in C [Module One]
Programming in C [Module One]
ย 
Fp201 unit2 1
Fp201 unit2 1Fp201 unit2 1
Fp201 unit2 1
ย 
#Code2 create c++ for beginners
#Code2 create  c++ for beginners #Code2 create  c++ for beginners
#Code2 create c++ for beginners
ย 
(2) cpp imperative programming
(2) cpp imperative programming(2) cpp imperative programming
(2) cpp imperative programming
ย 
C++ Constructs.pptx
C++ Constructs.pptxC++ Constructs.pptx
C++ Constructs.pptx
ย 
Csdfsadf
CsdfsadfCsdfsadf
Csdfsadf
ย 
C
CC
C
ย 
C
CC
C
ย 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
ย 
C_plus_plus
C_plus_plusC_plus_plus
C_plus_plus
ย 
Presentation 5th
Presentation 5thPresentation 5th
Presentation 5th
ย 
C tutorials
C tutorialsC tutorials
C tutorials
ย 
Lecture 1.pptx
Lecture 1.pptxLecture 1.pptx
Lecture 1.pptx
ย 
C++ L01-Variables
C++ L01-VariablesC++ L01-Variables
C++ L01-Variables
ย 
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
ย 

Recently uploaded

chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
ย 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
ย 
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night StandCall Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Standamitlee9823
ย 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
ย 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
ย 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
ย 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...tanu pandey
ย 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
ย 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
ย 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
ย 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
ย 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
ย 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
ย 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
ย 
Top Rated Call Girls In chittoor ๐Ÿ“ฑ {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor ๐Ÿ“ฑ {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor ๐Ÿ“ฑ {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor ๐Ÿ“ฑ {7001035870} VIP Escorts chittoordharasingh5698
ย 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01KreezheaRecto
ย 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7Call Girls in Nagpur High Profile Call Girls
ย 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
ย 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
ย 

Recently uploaded (20)

(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
ย 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
ย 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
ย 
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night StandCall Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
ย 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
ย 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
ย 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
ย 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
ย 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
ย 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
ย 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
ย 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
ย 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
ย 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
ย 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
ย 
Top Rated Call Girls In chittoor ๐Ÿ“ฑ {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor ๐Ÿ“ฑ {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor ๐Ÿ“ฑ {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor ๐Ÿ“ฑ {7001035870} VIP Escorts chittoor
ย 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
ย 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
ย 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
ย 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
ย 

Learning C++ - Introduction to c++ programming 1

  • 1. Introduction To C++ Programming Ali Aminian & Bardia Nezamzadeh 1
  • 2. Section Outline โ€ข Workspace โ€ข Basics of C++ Environment โ€ข Definition of Types โ€ข Operations in C++ 2
  • 3. Section Outline โ€ข Workspace โ€ข Basics of C++ Environment โ€ข Definition of Types โ€ข Operations in C++ 3
  • 4. Workspace โ€ข One of the most famous workspaces is โ€œMicrosoft Visual Studioโ€ โ€ข Creating a project : lets follow these pictures : 4
  • 6. Section Outline โ€ข Workspace โ€ข Basics of C++ Environment โ€ข Definition of Types โ€ข Operations in C++ 6
  • 7. โ€ข Comments -Single-line comment โ€ข Begin with : // this is comment (Fortran : !) -Multiple-line comment โ€ข Begin with : /* โ€ฆ /* this is a multiple line โ€ข End with : โ€ฆ*/ comment. We still have this line!*/ โ€ข Preprocessor directives -Processed by preprocessor before compiling -Begin with # include <math> Basics of C++ Environment 7 Adding math library to the project.
  • 8. โ€ข Different type of files in C++ โ€“ Header files (.h) โ€“ cpp files (.cpp) โ€“ Most important headers: ๏‚ง iostream.h ๏‚ง iomanip.h ๏‚ง math.h ๏‚ง cstdlib.h Basics of C++ Environment(cont.) Standard input/output Manipulate stream format Math library function Conversion function for text to number , number to text, memory allocation, random numbers and various other utility functions 8
  • 9. Basics of C++ Environment(cont.) โ€ข Program Framework int main() { โ€ฆโ€ฆโ€ฆโ€ฆโ€ฆโ€ฆ.. โ€ฆโ€ฆโ€ฆโ€ฆโ€ฆโ€ฆ.. โ€ฆโ€ฆโ€ฆโ€ฆโ€ฆโ€ฆ.. return 0; } (Frotran Framework:) PROGRAM name โ€ฆโ€ฆโ€ฆโ€ฆโ€ฆโ€ฆ.. โ€ฆโ€ฆโ€ฆโ€ฆโ€ฆโ€ฆ.. โ€ฆโ€ฆโ€ฆโ€ฆโ€ฆโ€ฆ.. END 9
  • 10. โ€ข Some important Syntaxes โ€“ include<> โ€“ main() โ€“ cin>> , cout<< โ€ข These are like READ , PRINT โ€“ ; (Semicolon) โ€ข Shows the end of line . (works the same as in Fortran) Basics of C++ Environment(cont.) In next slides we introduce the other syntax symbols, these are most familiar for any program which we could see in any code 10
  • 11. Basics of C++ Environment(cont.) Phases of C++ Programs: 1. Edit 2. Preprocess 3. Compile 4. Link 5. Load 6. Execute Loader Primary Memory Program is created in the editor and stored on disk. Preprocessor program processes the code. Loader puts program in memory. CPU takes each instruction and executes it, possibly storing new data values as the program executes. Compiler Compiler creates object code and stores it on disk. Linker links the object code with the libraries, creates a.out and stores it on disk Editor Preprocessor Linker CPU Primary Memory . . . . . . . . . . . . Disk Disk Disk Disk Disk 11
  • 12. Basics of C++ Environment(cont.) 1 // Printing multiple lines with a single statement 2 #include <iostream> 3 4 // function main begins program execution 5 int main() 6 { 7 std::cout << "Welcome to C++!n"; 8 9 return 0; // indicate that program ended successfully 10 11 } // end function main Comments Preprocessor directive to include input/output stream header file <iostream> We include this library to use the std::cout command for printing. Function main appears exactly once in every C++ program.. Special Characters We use these characters to write some characters that can not be written in normal way: n Enter t Tab backslash itself! Keyword return is one of several means to exit function; value 0 indicates program terminated successfully. Welcome to C++! Output: 12
  • 13. Section Outline โ€ข Workspace โ€ข Basics of C++ Environment โ€ข Definition of Types โ€ข Operations in C++ 13
  • 14. Definition of Types โ€ข Floating point variables โ€“ float : 6 digits after floating point โ€“ double : 12 digits after floating point (more precision) All of above types are useful to store real values such as: 0.12E5 Or 2.3212 14
  • 15. Definition of Types(cont.) โ€ข Integer variables We can use following words to do some alternative with int type: โ€“ short โ€“ unsigned int โ€“ unsigned short โ€“ long โ€“ int โ€“ unsigned long These words change range and starting point of integer variables : e.g. short int a; //range -32768 to 32767 15
  • 16. Type Min. range Max. range short -32768 32767 unsigned short 0 65535 int -2147483648 2147483647 unsigned int 0 4294967295 long -9223372036854775808 9223372036854775807 unsigned long 0 18446744073709551615 Definition of Types(cont.) 16
  • 17. Definition of Types(cont.) โ€ข bool โ€“ This type has just two values: (true, false) โ€“ Note : in Fortran we use LOGICAL and .true. And .false. combination Instead. โ€ข char โ€“ This type is used to store ASCII characters โ€“ e.g. char a =โ€˜Qโ€™; โ€ข enum โ€“ It creates a list, in witch every elements has a number and we can use the elements instead of numbers (notice to example in next slide) 17
  • 18. Definition of Types(cont.) E.G. : If we define such an enum : enum Day{SAT,SUN,MON,TUE,WED,THU,FRI} Now if we define a variable from Day type then this variable can accept the values that define Inside the Day type such as SAT, SUN, MON,โ€ฆ e.g. Day mybirthday = MON; 18
  • 19. Definition of Types(cont.) NOTES: ๏ƒผvariable precision: 1.2 / 2 returns integer or double? ๏ƒผCasting: e.g. : a = (int) c; //a is int and c is double (c was 12.63) If we didnโ€™t use cast in this example, C++ would store 12 inside a. 19
  • 20. Definition of Types(cont.) โ€ข We can have our own types with typedef keyword. e.g. typedef long double real; real a; //a is a long double variable now 20 Exactly the same type in C++Type in Fortran shortINTEGER *2 intINTEGER *4 long intINTEGER *8 floatREAL*4 doubleREAL*8 long doubleREAL*16 charCHARACTER boolLOGICAL
  • 21. Basics of C++ Environment(cont.) โ€ข MORE NOTES! ๏ƒผ we use const command to define constant variables ( Fortran : PARAMETER ) e.g. const int a = 12; ๏ƒผ there is no need to write & when we want to write multiple line commands ๏ƒผ C++ is a case sensitive language ( vs. Fortran ) 21
  • 22. Section Outline โ€ข Workspace โ€ข Basics of C++ Environment โ€ข Definition of Types โ€ข Operations in C++ 22
  • 23. Operations in C++ โ€ข Conditional operands other operands : < , <= , => , > 23 FortranC++ .AND.&&And .OR.||Or .NEQV.!=Not equivalent .EQV.==Equivalent
  • 24. Operations in C++ โ€ข If (condition) {statement } โ€ข If , else if (a==true) { b=b+1; } else { b=b-1; } It is important that how compiler , compile these operations 24
  • 25. Operations in C++ โ€ข for(init;condition;command) {statement} for(i=0; i<10; i++) { b--; // b=b-1 } variable i will advance from 0 itself to 9 itself during the loop 25
  • 26. Operations in C++ โ€ข while(condition) {statement} while(a)//if a is true { b++; // b=b+1 if(b==100) { break; } } ๏ฑ notes : ๏ƒ˜break: breaks the loop and steps out ๏ƒ˜Ctrl+C: manually breaking the loop! 26
  • 27. Operations in C++(cont.) โ€ข Variable++ / ++Variable x=y++ is different from x=++y โ€ข > , < , => , != , == (Comparisons operand) , = โ€ข ||, && (Logical operand) โ€ข condition ? expression1 : expression2 โ€“ if(condition) {expression1 } else {expression2} โ€ข goto : label you must know what want to do exactly otherwise this is very dangerous ! 27
  • 28. In future : i. Pointers and related argues ii. Functions iii.Class and related concepts iv.ERRORS 28

Editor's Notes

  1. Comments : (//)make a line comment wherever it appear until end line Preprocessor examples : 1.includes 2.defines
  2. Comments : (//)make a line comment wherever it appear until end line Preprocessor examples : 1.includes 2.defines
  3. Comments : (//)make a line comment wherever it appear until end line Preprocessor examples : 1.includes 2.defines
  4. Comments : (//)make a line comment wherever it appear until end line Preprocessor examples : 1.includes 2.defines
  5. Comments : (//)make a line comment wherever it appear until end line Preprocessor examples : 1.includes 2.defines
  6. Comments : (//)make a line comment wherever it appear until end line Preprocessor examples : 1.includes 2.defines
  7. Comments : (//)make a line comment wherever it appear until end line Preprocessor examples : 1.includes 2.defines