SlideShare uma empresa Scribd logo
1 de 37
Migration: C to C++ 09/09/2009 1 Hadziq Fabroyir - Informatics ITS
C/C++ Program Structure Operating System void function1() { 	//... 	return; } int main() { 	function1(); 	function2(); 	function3(); 	return 0; } void function2() { 	//... 	return; } void function3() { 	//... 	return; } Operating System
Naming Variable MUST Identifier / variable name can include letters(A-z), digits(0-9), and underscore(_) Identifier starts with letteror underscore Do NOT use keywordsas identifier Identifier in C++ is case-sensitive CONSIDER Usemeaningfullname Limit identifier length up to 31 characters, although it can have length up to 2048 Avoid using identifiers that start with an underscore 09/09/2009 Hadziq Fabroyir - Informatics ITS 3
Keywords 09/09/2009 Hadziq Fabroyir - Informatics ITS 4
Declaring Variable 09/09/2009 Hadziq Fabroyir - Informatics ITS 5 int value; char[] firstName; Char[] address;	 int 9ball; long bigInt; System::String full_name; int count!; long class; float a234_djJ_685_abc___;
Initializing Variable int value = 0;					 char[] firstName = “Budi”;				 long bigInt(100L); System::String^ full_name = “Budi Lagi”; 09/09/2009 Hadziq Fabroyir - Informatics ITS 6
Fundamental Data Types 09/09/2009 Hadziq Fabroyir - Informatics ITS 7
Literals 09/09/2009 Hadziq Fabroyir - Informatics ITS 8
Example of Data Types int main() { 	char c = 'A'; 	wchar_t wideChar = L'9'; 	int i = 123; 	long l = 10240L; 	float f = 3.14f; 	double d = 3.14; 	bool b = true; 	return 0; } 09/09/2009 Hadziq Fabroyir - Informatics ITS 9
Enumerations Variable with specific sets of values Enum Day {Mon, Tues, Wed, Thurs, Fri, Sat, Sun}; Day today = Mon; Enum Day {Mon = 1, Tues, Wed, Thurs, Fri, Sat, Sun}; Day nextDay = Tues; 09/09/2009 Hadziq Fabroyir - Informatics ITS 10
Basic Input/Output Operations int main() { 	//declare and initialize variables 	int num1 = 0; 	int num2 = 0; 	//getting input from keyboard 	cin >> num1 >> num2; 	//output the variables value to command line 	cout << endl; 	cout << "Num1 : " << num1 << endl; 	cout << "Num2 : " << num2; 	return 0; } 09/09/2009 Hadziq Fabroyir - Informatics ITS 11
Escape Sequence 09/09/2009 Hadziq Fabroyir - Informatics ITS 12
Basic Operators int main() { 	int a = 0; 	int b = 0; 	int c = 0; 	c = a + b; 	c = a - b; 	c = a * b; 	c = a / b; 	c = a % b; 	a = -b;	 	return 0; } 09/09/2009 Hadziq Fabroyir - Informatics ITS 13
Bitwise Operators 09/09/2009 Hadziq Fabroyir - Informatics ITS 14 &	bitwise AND ~ 	bitwise NOT | 	bitwise OR ^ 	bitwise XOR >>shift right <<shift left
Increment and Decrement Operators int main() { 	int a = 0; 	int b = 0; 	a++; 	b--; ++a; 	++b;	 	return 0; } 09/09/2009 Hadziq Fabroyir - Informatics ITS 15
Shorthand Operators int main() { 	int a = 0; 	int b = 0; 	a += 3; 	b -= a; 	a *= 2; 	b /= 32; 	a %= b;	 	return 0; } 09/09/2009 Hadziq Fabroyir - Informatics ITS 16
Explicit Casting static_cast<the_type_to_convert_to>(expression) (the_type_to_convert_to)expression 09/09/2009 Hadziq Fabroyir - Informatics ITS 17
Constant Declaration int main() { const double rollwidth = 21.0;    const double rolllength = 12.0*33.0;    const double rollarea = rollwidth*rolllength;    return 0; } 09/09/2009 Hadziq Fabroyir - Informatics ITS 18
Declaring Namespace namespace MyNamespace { 	// code belongs to myNamespace } namespace OtherNamespace { 	// code belongs to otherNamespace } 09/09/2009 Hadziq Fabroyir - Informatics ITS 19
Using Namespace #include <iostream> namespace myStuff { int value = 0; } int main() { std::cout << “enter an integer: “; std::cin >> myStuff::value; std::cout << “You entered “ << myStuff::value << std:: endl; return 0; } #include <iostream> namespace myStuff {            int value = 0; } using namespace myStuff; int main() { std::cout << “enter an integer: “; std::cin >> value; std::cout << “You entered “ << value<< std:: endl; return 0; } 09/09/2009 Hadziq Fabroyir - Informatics ITS 20
Visual C++ Programming Environment Hadziq Fabroyir - Informatics ITS ISO/ANSI C++ (unmanaged) C++/CLI .NET Framework Managed C++ Native C++ Framework Classes Native C++ MFC Common Language Runtime (CLR) Operating System HHardware 09/09/2009 21
C++/CLI Data Types 09/09/2009 Hadziq Fabroyir - Informatics ITS 22
ITC1398 Introduction to Programming Chapter 3 23 Control Structures Three control structures  Sequence structure Programs executed sequentially by default Selection structures if, if…else, switch Repetition structures while, do…while, for
ITC1398 Introduction to Programming Chapter 3 24 if Selection Statement Choose among alternative courses of action Pseudocode example If student’s grade is greater than or equal to 60      print “Passed” If the condition is true Print statement executes, program continues to next statement If the condition is false Print statement ignored, program continues
Activity Diagram 09/09/2009 Hadziq Fabroyir - Informatics ITS 25
ITC1398 Introduction to Programming Chapter 3 26 if Selection Statement Translation into C++ if ( grade >= 60 )    cout << "Passed"; Any expression can be used as the condition If it evaluates to zero, it is treated as false If it evaluates to non-zero, it is treated as true
ITC1398 Introduction to Programming Chapter 3 27 if…else Double-Selection Statement if Performs action if condition true if…else Performs one action if condition is true, a different action if it is false Pseudocode If student’s grade is greater than or equal to 60     print “Passed”Else     print “Failed”  C++ code if ( grade >= 60 )    cout << "Passed";else   cout << "Failed";
Activity Diagram 09/09/2009 Hadziq Fabroyir - Informatics ITS 28
ITC1398 Introduction to Programming Chapter 3 29 if…else Double-Selection Statement Ternary conditional operator (?:) Three arguments (condition, value if true, value if false) Code could be written: cout << ( grade >= 60 ? “Passed” : “Failed” ); Condition Value if true Value if false
ITC1398 Introduction to Programming Chapter 3 30 if…else Double-Selection Statement Nested if…else statements One inside another, test for multiple cases  Once a condition met, other statements are skipped Example              If student’s grade is greater than or equal to 90                   Print “A”              Else           If student’s grade is greater than or equal to 80	              Print “B”         Else                If student’s grade is greater than or equal to 70 	                    Print “C”	               Else 	                    If student’s grade is greater than or equal to 60 	                         Print “D”                    Else                            Print “F”
ITC1398 Introduction to Programming Chapter 3 31 if…else Double-Selection Statement Nested if…else statements (Cont.) Written In C++ if ( studentGrade >= 90 )    cout << "A";elseif (studentGrade >= 80 )       cout << "B";elseif (studentGrade >= 70 )          cout << "C";  elseif ( studentGrade >= 60 )             cout << "D";else            cout << "F";
while Repetition Statement A repetition statement (also called a looping statement or a loop) allows the programmer to specify that a program should repeat an action while some condition remains true. The pseudocode statement While there are more items on my shopping list Purchase next item and cross it off my list  09/09/2009 Hadziq Fabroyir - Informatics ITS 32
for Repetition Statement 09/09/2009 Hadziq Fabroyir - Informatics ITS 33
do …while Repetition Statement do {  statement  } while ( condition ); 09/09/2009 Hadziq Fabroyir - Informatics ITS 34
switch Multiple-Selection Statement 09/09/2009 Hadziq Fabroyir - Informatics ITS 35
For your practice … Lab Session I (Ahad, 19.00-21.00) 4.14  5.20  6.27 Lab Session II (Senin, 19.00-21.00) 4.35  5.12  6.30 09/09/2009 Hadziq Fabroyir - Informatics ITS 36
☺~ Next: OOP using C++ ~☺ [ 37 ] Hadziq Fabroyir - Informatics ITS 09/09/2009

Mais conteúdo relacionado

Mais procurados

C programming session 02
C programming session 02C programming session 02
C programming session 02
Vivek Singh
 

Mais procurados (20)

Deep C
Deep CDeep C
Deep C
 
Programming fundamental 02
Programming fundamental 02Programming fundamental 02
Programming fundamental 02
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
 
Glimpses of C++0x
Glimpses of C++0xGlimpses of C++0x
Glimpses of C++0x
 
Unit 2 c programming_basics
Unit 2 c programming_basicsUnit 2 c programming_basics
Unit 2 c programming_basics
 
Programming C Part 03
Programming C Part 03Programming C Part 03
Programming C Part 03
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
Object-Oriented Programming in Modern C++. Borislav Stanimirov. CoreHard Spri...
Object-Oriented Programming in Modern C++. Borislav Stanimirov. CoreHard Spri...Object-Oriented Programming in Modern C++. Borislav Stanimirov. CoreHard Spri...
Object-Oriented Programming in Modern C++. Borislav Stanimirov. CoreHard Spri...
 
VTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in CVTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in C
 
Control Statements, Array, Pointer, Structures
Control Statements, Array, Pointer, StructuresControl Statements, Array, Pointer, Structures
Control Statements, Array, Pointer, Structures
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Basics of C porgramming
Basics of C porgrammingBasics of C porgramming
Basics of C porgramming
 
Chap 2 input output dti2143
Chap 2  input output dti2143Chap 2  input output dti2143
Chap 2 input output dti2143
 
Overview of c++ language
Overview of c++ language   Overview of c++ language
Overview of c++ language
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
 
Important C program of Balagurusamy Book
Important C program of Balagurusamy BookImportant C program of Balagurusamy Book
Important C program of Balagurusamy Book
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
C if else
C if elseC if else
C if else
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
Programming with c language practical manual
Programming with c language practical manualProgramming with c language practical manual
Programming with c language practical manual
 

Destaque (6)

#OOP_D_ITS - 3rd - Pointer And References
#OOP_D_ITS - 3rd - Pointer And References#OOP_D_ITS - 3rd - Pointer And References
#OOP_D_ITS - 3rd - Pointer And References
 
#OOP_D_ITS - 8th - Class Diagram
#OOP_D_ITS - 8th - Class Diagram#OOP_D_ITS - 8th - Class Diagram
#OOP_D_ITS - 8th - Class Diagram
 
10 Curso de POO en java - métodos modificadores y analizadores
10 Curso de POO en java - métodos modificadores y analizadores10 Curso de POO en java - métodos modificadores y analizadores
10 Curso de POO en java - métodos modificadores y analizadores
 
18 Curso POO en java - contenedores
18 Curso POO en java - contenedores18 Curso POO en java - contenedores
18 Curso POO en java - contenedores
 
11 Curso de POO en java - métodos constructores y toString()
11 Curso de POO en java - métodos constructores y toString()11 Curso de POO en java - métodos constructores y toString()
11 Curso de POO en java - métodos constructores y toString()
 
8b Curso de POO en java - paso de diagrama clases a java 1
8b Curso de POO en java - paso de diagrama clases a java 18b Curso de POO en java - paso de diagrama clases a java 1
8b Curso de POO en java - paso de diagrama clases a java 1
 

Semelhante a #OOP_D_ITS - 3rd - Migration From C To C++

presentation_python_11_1569171345_375360.pptx
presentation_python_11_1569171345_375360.pptxpresentation_python_11_1569171345_375360.pptx
presentation_python_11_1569171345_375360.pptx
GAURAVRATHORE86
 
C++ Programming Club-Lecture 2
C++ Programming Club-Lecture 2C++ Programming Club-Lecture 2
C++ Programming Club-Lecture 2
Ammara Javed
 

Semelhante a #OOP_D_ITS - 3rd - Migration From C To C++ (20)

operators.ppt
operators.pptoperators.ppt
operators.ppt
 
Elements of programming
Elements of programmingElements of programming
Elements of programming
 
Programming basics
Programming basicsProgramming basics
Programming basics
 
CP Handout#4
CP Handout#4CP Handout#4
CP Handout#4
 
presentation_python_11_1569171345_375360.pptx
presentation_python_11_1569171345_375360.pptxpresentation_python_11_1569171345_375360.pptx
presentation_python_11_1569171345_375360.pptx
 
C++ Programming Club-Lecture 2
C++ Programming Club-Lecture 2C++ Programming Club-Lecture 2
C++ Programming Club-Lecture 2
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
 
C Programming
C ProgrammingC Programming
C Programming
 
Control All
Control AllControl All
Control All
 
175035 cse lab-05
175035 cse lab-05 175035 cse lab-05
175035 cse lab-05
 
COM1407: Program Control Structures – Decision Making & Branching
COM1407: Program Control Structures – Decision Making & BranchingCOM1407: Program Control Structures – Decision Making & Branching
COM1407: Program Control Structures – Decision Making & Branching
 
Statement
StatementStatement
Statement
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
 
Ch4
Ch4Ch4
Ch4
 
ICP - Lecture 7 and 8
ICP - Lecture 7 and 8ICP - Lecture 7 and 8
ICP - Lecture 7 and 8
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures
 
Understand more about C
Understand more about CUnderstand more about C
Understand more about C
 

Mais de Hadziq Fabroyir

Living in Taiwan for Dummies
Living in Taiwan for DummiesLiving in Taiwan for Dummies
Living in Taiwan for Dummies
Hadziq Fabroyir
 
NTUST Course Selection - How to
NTUST Course Selection - How toNTUST Course Selection - How to
NTUST Course Selection - How to
Hadziq Fabroyir
 
#OOP_D_ITS - 9th - Template
#OOP_D_ITS - 9th - Template#OOP_D_ITS - 9th - Template
#OOP_D_ITS - 9th - Template
Hadziq Fabroyir
 
#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance
Hadziq Fabroyir
 
#OOP_D_ITS - 5th - C++ Oop Operator Overloading
#OOP_D_ITS - 5th - C++ Oop Operator Overloading#OOP_D_ITS - 5th - C++ Oop Operator Overloading
#OOP_D_ITS - 5th - C++ Oop Operator Overloading
Hadziq Fabroyir
 
#OOP_D_ITS - 2nd - C++ Getting Started
#OOP_D_ITS - 2nd - C++ Getting Started#OOP_D_ITS - 2nd - C++ Getting Started
#OOP_D_ITS - 2nd - C++ Getting Started
Hadziq Fabroyir
 
#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure
Hadziq Fabroyir
 

Mais de Hadziq Fabroyir (20)

An Immersive Map Exploration System Using Handheld Device
An Immersive Map Exploration System Using Handheld DeviceAn Immersive Map Exploration System Using Handheld Device
An Immersive Map Exploration System Using Handheld Device
 
在不同尺度遙現系統中具空間感知特性的使用者介面開發
在不同尺度遙現系統中具空間感知特性的使用者介面開發在不同尺度遙現系統中具空間感知特性的使用者介面開發
在不同尺度遙現系統中具空間感知特性的使用者介面開發
 
NTUST Course Selection (Revision: Fall 2016)
NTUST Course Selection (Revision: Fall 2016)NTUST Course Selection (Revision: Fall 2016)
NTUST Course Selection (Revision: Fall 2016)
 
律法保護的五件事
律法保護的五件事律法保護的五件事
律法保護的五件事
 
Pelajaran 5 第五課 • Telepon 給打電話
Pelajaran 5 第五課 • Telepon 給打電話Pelajaran 5 第五課 • Telepon 給打電話
Pelajaran 5 第五課 • Telepon 給打電話
 
Pelajaran 4 第四課 • Belanja 買東西
Pelajaran 4 第四課 • Belanja 買東西Pelajaran 4 第四課 • Belanja 買東西
Pelajaran 4 第四課 • Belanja 買東西
 
Pelajaran 3 第三課 • Transportasi 交通
Pelajaran 3 第三課 • Transportasi 交通Pelajaran 3 第三課 • Transportasi 交通
Pelajaran 3 第三課 • Transportasi 交通
 
Pelajaran 2 第二課 • Di Restoran 在餐廳
Pelajaran 2 第二課 • Di Restoran 在餐廳Pelajaran 2 第二課 • Di Restoran 在餐廳
Pelajaran 2 第二課 • Di Restoran 在餐廳
 
Pelajaran 1 第一課 • Perkenalan Diri 自我介紹
Pelajaran 1 第一課 • Perkenalan Diri 自我介紹Pelajaran 1 第一課 • Perkenalan Diri 自我介紹
Pelajaran 1 第一課 • Perkenalan Diri 自我介紹
 
Living in Taiwan for Dummies
Living in Taiwan for DummiesLiving in Taiwan for Dummies
Living in Taiwan for Dummies
 
How to Select Course at NTUST
How to Select Course at NTUSTHow to Select Course at NTUST
How to Select Course at NTUST
 
NTUST-IMSA • International Students Orientation
NTUST-IMSA • International Students OrientationNTUST-IMSA • International Students Orientation
NTUST-IMSA • International Students Orientation
 
NTUST Course Selection - How to
NTUST Course Selection - How toNTUST Course Selection - How to
NTUST Course Selection - How to
 
Brain Battle Online
Brain Battle OnlineBrain Battle Online
Brain Battle Online
 
Manajemen Waktu
Manajemen WaktuManajemen Waktu
Manajemen Waktu
 
#OOP_D_ITS - 9th - Template
#OOP_D_ITS - 9th - Template#OOP_D_ITS - 9th - Template
#OOP_D_ITS - 9th - Template
 
#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance
 
#OOP_D_ITS - 5th - C++ Oop Operator Overloading
#OOP_D_ITS - 5th - C++ Oop Operator Overloading#OOP_D_ITS - 5th - C++ Oop Operator Overloading
#OOP_D_ITS - 5th - C++ Oop Operator Overloading
 
#OOP_D_ITS - 2nd - C++ Getting Started
#OOP_D_ITS - 2nd - C++ Getting Started#OOP_D_ITS - 2nd - C++ Getting Started
#OOP_D_ITS - 2nd - C++ Getting Started
 
#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure
 

Último

Call Girl in Indore 8827247818 {LowPrice} ❤️ (ahana) Indore Call Girls * UPA...
Call Girl in Indore 8827247818 {LowPrice} ❤️ (ahana) Indore Call Girls  * UPA...Call Girl in Indore 8827247818 {LowPrice} ❤️ (ahana) Indore Call Girls  * UPA...
Call Girl in Indore 8827247818 {LowPrice} ❤️ (ahana) Indore Call Girls * UPA...
mahaiklolahd
 
Call Girl In Pune 👉 Just CALL ME: 9352988975 💋 Call Out Call Both With High p...
Call Girl In Pune 👉 Just CALL ME: 9352988975 💋 Call Out Call Both With High p...Call Girl In Pune 👉 Just CALL ME: 9352988975 💋 Call Out Call Both With High p...
Call Girl In Pune 👉 Just CALL ME: 9352988975 💋 Call Out Call Both With High p...
chetankumar9855
 

Último (20)

Manyata Tech Park ( Call Girls ) Bangalore ✔ 6297143586 ✔ Hot Model With Sexy...
Manyata Tech Park ( Call Girls ) Bangalore ✔ 6297143586 ✔ Hot Model With Sexy...Manyata Tech Park ( Call Girls ) Bangalore ✔ 6297143586 ✔ Hot Model With Sexy...
Manyata Tech Park ( Call Girls ) Bangalore ✔ 6297143586 ✔ Hot Model With Sexy...
 
Top Rated Hyderabad Call Girls Erragadda ⟟ 9332606886 ⟟ Call Me For Genuine ...
Top Rated  Hyderabad Call Girls Erragadda ⟟ 9332606886 ⟟ Call Me For Genuine ...Top Rated  Hyderabad Call Girls Erragadda ⟟ 9332606886 ⟟ Call Me For Genuine ...
Top Rated Hyderabad Call Girls Erragadda ⟟ 9332606886 ⟟ Call Me For Genuine ...
 
Call Girls Ahmedabad Just Call 9630942363 Top Class Call Girl Service Available
Call Girls Ahmedabad Just Call 9630942363 Top Class Call Girl Service AvailableCall Girls Ahmedabad Just Call 9630942363 Top Class Call Girl Service Available
Call Girls Ahmedabad Just Call 9630942363 Top Class Call Girl Service Available
 
Call Girls Kakinada Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Kakinada Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Kakinada Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Kakinada Just Call 9907093804 Top Class Call Girl Service Available
 
8980367676 Call Girls In Ahmedabad Escort Service Available 24×7 In Ahmedabad
8980367676 Call Girls In Ahmedabad Escort Service Available 24×7 In Ahmedabad8980367676 Call Girls In Ahmedabad Escort Service Available 24×7 In Ahmedabad
8980367676 Call Girls In Ahmedabad Escort Service Available 24×7 In Ahmedabad
 
Call Girl in Indore 8827247818 {LowPrice} ❤️ (ahana) Indore Call Girls * UPA...
Call Girl in Indore 8827247818 {LowPrice} ❤️ (ahana) Indore Call Girls  * UPA...Call Girl in Indore 8827247818 {LowPrice} ❤️ (ahana) Indore Call Girls  * UPA...
Call Girl in Indore 8827247818 {LowPrice} ❤️ (ahana) Indore Call Girls * UPA...
 
💕SONAM KUMAR💕Premium Call Girls Jaipur ↘️9257276172 ↙️One Night Stand With Lo...
💕SONAM KUMAR💕Premium Call Girls Jaipur ↘️9257276172 ↙️One Night Stand With Lo...💕SONAM KUMAR💕Premium Call Girls Jaipur ↘️9257276172 ↙️One Night Stand With Lo...
💕SONAM KUMAR💕Premium Call Girls Jaipur ↘️9257276172 ↙️One Night Stand With Lo...
 
Call Girls Shimla Just Call 8617370543 Top Class Call Girl Service Available
Call Girls Shimla Just Call 8617370543 Top Class Call Girl Service AvailableCall Girls Shimla Just Call 8617370543 Top Class Call Girl Service Available
Call Girls Shimla Just Call 8617370543 Top Class Call Girl Service Available
 
Call Girls Raipur Just Call 9630942363 Top Class Call Girl Service Available
Call Girls Raipur Just Call 9630942363 Top Class Call Girl Service AvailableCall Girls Raipur Just Call 9630942363 Top Class Call Girl Service Available
Call Girls Raipur Just Call 9630942363 Top Class Call Girl Service Available
 
Call Girls Visakhapatnam Just Call 8250077686 Top Class Call Girl Service Ava...
Call Girls Visakhapatnam Just Call 8250077686 Top Class Call Girl Service Ava...Call Girls Visakhapatnam Just Call 8250077686 Top Class Call Girl Service Ava...
Call Girls Visakhapatnam Just Call 8250077686 Top Class Call Girl Service Ava...
 
Call Girls Hosur Just Call 9630942363 Top Class Call Girl Service Available
Call Girls Hosur Just Call 9630942363 Top Class Call Girl Service AvailableCall Girls Hosur Just Call 9630942363 Top Class Call Girl Service Available
Call Girls Hosur Just Call 9630942363 Top Class Call Girl Service Available
 
Premium Call Girls In Jaipur {8445551418} ❤️VVIP SEEMA Call Girl in Jaipur Ra...
Premium Call Girls In Jaipur {8445551418} ❤️VVIP SEEMA Call Girl in Jaipur Ra...Premium Call Girls In Jaipur {8445551418} ❤️VVIP SEEMA Call Girl in Jaipur Ra...
Premium Call Girls In Jaipur {8445551418} ❤️VVIP SEEMA Call Girl in Jaipur Ra...
 
Call Girls Rishikesh Just Call 8250077686 Top Class Call Girl Service Available
Call Girls Rishikesh Just Call 8250077686 Top Class Call Girl Service AvailableCall Girls Rishikesh Just Call 8250077686 Top Class Call Girl Service Available
Call Girls Rishikesh Just Call 8250077686 Top Class Call Girl Service Available
 
Top Rated Bangalore Call Girls Ramamurthy Nagar ⟟ 9332606886 ⟟ Call Me For G...
Top Rated Bangalore Call Girls Ramamurthy Nagar ⟟  9332606886 ⟟ Call Me For G...Top Rated Bangalore Call Girls Ramamurthy Nagar ⟟  9332606886 ⟟ Call Me For G...
Top Rated Bangalore Call Girls Ramamurthy Nagar ⟟ 9332606886 ⟟ Call Me For G...
 
Top Rated Bangalore Call Girls Majestic ⟟ 9332606886 ⟟ Call Me For Genuine S...
Top Rated Bangalore Call Girls Majestic ⟟  9332606886 ⟟ Call Me For Genuine S...Top Rated Bangalore Call Girls Majestic ⟟  9332606886 ⟟ Call Me For Genuine S...
Top Rated Bangalore Call Girls Majestic ⟟ 9332606886 ⟟ Call Me For Genuine S...
 
Call Girls Vasai Virar Just Call 9630942363 Top Class Call Girl Service Avail...
Call Girls Vasai Virar Just Call 9630942363 Top Class Call Girl Service Avail...Call Girls Vasai Virar Just Call 9630942363 Top Class Call Girl Service Avail...
Call Girls Vasai Virar Just Call 9630942363 Top Class Call Girl Service Avail...
 
Call Girl In Pune 👉 Just CALL ME: 9352988975 💋 Call Out Call Both With High p...
Call Girl In Pune 👉 Just CALL ME: 9352988975 💋 Call Out Call Both With High p...Call Girl In Pune 👉 Just CALL ME: 9352988975 💋 Call Out Call Both With High p...
Call Girl In Pune 👉 Just CALL ME: 9352988975 💋 Call Out Call Both With High p...
 
Trichy Call Girls Book Now 9630942363 Top Class Trichy Escort Service Available
Trichy Call Girls Book Now 9630942363 Top Class Trichy Escort Service AvailableTrichy Call Girls Book Now 9630942363 Top Class Trichy Escort Service Available
Trichy Call Girls Book Now 9630942363 Top Class Trichy Escort Service Available
 
Call Girls in Delhi Triveni Complex Escort Service(🔝))/WhatsApp 97111⇛47426
Call Girls in Delhi Triveni Complex Escort Service(🔝))/WhatsApp 97111⇛47426Call Girls in Delhi Triveni Complex Escort Service(🔝))/WhatsApp 97111⇛47426
Call Girls in Delhi Triveni Complex Escort Service(🔝))/WhatsApp 97111⇛47426
 
All Time Service Available Call Girls Marine Drive 📳 9820252231 For 18+ VIP C...
All Time Service Available Call Girls Marine Drive 📳 9820252231 For 18+ VIP C...All Time Service Available Call Girls Marine Drive 📳 9820252231 For 18+ VIP C...
All Time Service Available Call Girls Marine Drive 📳 9820252231 For 18+ VIP C...
 

#OOP_D_ITS - 3rd - Migration From C To C++

  • 1. Migration: C to C++ 09/09/2009 1 Hadziq Fabroyir - Informatics ITS
  • 2. C/C++ Program Structure Operating System void function1() { //... return; } int main() { function1(); function2(); function3(); return 0; } void function2() { //... return; } void function3() { //... return; } Operating System
  • 3. Naming Variable MUST Identifier / variable name can include letters(A-z), digits(0-9), and underscore(_) Identifier starts with letteror underscore Do NOT use keywordsas identifier Identifier in C++ is case-sensitive CONSIDER Usemeaningfullname Limit identifier length up to 31 characters, although it can have length up to 2048 Avoid using identifiers that start with an underscore 09/09/2009 Hadziq Fabroyir - Informatics ITS 3
  • 4. Keywords 09/09/2009 Hadziq Fabroyir - Informatics ITS 4
  • 5. Declaring Variable 09/09/2009 Hadziq Fabroyir - Informatics ITS 5 int value; char[] firstName; Char[] address; int 9ball; long bigInt; System::String full_name; int count!; long class; float a234_djJ_685_abc___;
  • 6. Initializing Variable int value = 0; char[] firstName = “Budi”; long bigInt(100L); System::String^ full_name = “Budi Lagi”; 09/09/2009 Hadziq Fabroyir - Informatics ITS 6
  • 7. Fundamental Data Types 09/09/2009 Hadziq Fabroyir - Informatics ITS 7
  • 8. Literals 09/09/2009 Hadziq Fabroyir - Informatics ITS 8
  • 9. Example of Data Types int main() { char c = 'A'; wchar_t wideChar = L'9'; int i = 123; long l = 10240L; float f = 3.14f; double d = 3.14; bool b = true; return 0; } 09/09/2009 Hadziq Fabroyir - Informatics ITS 9
  • 10. Enumerations Variable with specific sets of values Enum Day {Mon, Tues, Wed, Thurs, Fri, Sat, Sun}; Day today = Mon; Enum Day {Mon = 1, Tues, Wed, Thurs, Fri, Sat, Sun}; Day nextDay = Tues; 09/09/2009 Hadziq Fabroyir - Informatics ITS 10
  • 11. Basic Input/Output Operations int main() { //declare and initialize variables int num1 = 0; int num2 = 0; //getting input from keyboard cin >> num1 >> num2; //output the variables value to command line cout << endl; cout << "Num1 : " << num1 << endl; cout << "Num2 : " << num2; return 0; } 09/09/2009 Hadziq Fabroyir - Informatics ITS 11
  • 12. Escape Sequence 09/09/2009 Hadziq Fabroyir - Informatics ITS 12
  • 13. Basic Operators int main() { int a = 0; int b = 0; int c = 0; c = a + b; c = a - b; c = a * b; c = a / b; c = a % b; a = -b; return 0; } 09/09/2009 Hadziq Fabroyir - Informatics ITS 13
  • 14. Bitwise Operators 09/09/2009 Hadziq Fabroyir - Informatics ITS 14 & bitwise AND ~ bitwise NOT | bitwise OR ^ bitwise XOR >>shift right <<shift left
  • 15. Increment and Decrement Operators int main() { int a = 0; int b = 0; a++; b--; ++a; ++b; return 0; } 09/09/2009 Hadziq Fabroyir - Informatics ITS 15
  • 16. Shorthand Operators int main() { int a = 0; int b = 0; a += 3; b -= a; a *= 2; b /= 32; a %= b; return 0; } 09/09/2009 Hadziq Fabroyir - Informatics ITS 16
  • 17. Explicit Casting static_cast<the_type_to_convert_to>(expression) (the_type_to_convert_to)expression 09/09/2009 Hadziq Fabroyir - Informatics ITS 17
  • 18. Constant Declaration int main() { const double rollwidth = 21.0; const double rolllength = 12.0*33.0; const double rollarea = rollwidth*rolllength; return 0; } 09/09/2009 Hadziq Fabroyir - Informatics ITS 18
  • 19. Declaring Namespace namespace MyNamespace { // code belongs to myNamespace } namespace OtherNamespace { // code belongs to otherNamespace } 09/09/2009 Hadziq Fabroyir - Informatics ITS 19
  • 20. Using Namespace #include <iostream> namespace myStuff { int value = 0; } int main() { std::cout << “enter an integer: “; std::cin >> myStuff::value; std::cout << “You entered “ << myStuff::value << std:: endl; return 0; } #include <iostream> namespace myStuff { int value = 0; } using namespace myStuff; int main() { std::cout << “enter an integer: “; std::cin >> value; std::cout << “You entered “ << value<< std:: endl; return 0; } 09/09/2009 Hadziq Fabroyir - Informatics ITS 20
  • 21. Visual C++ Programming Environment Hadziq Fabroyir - Informatics ITS ISO/ANSI C++ (unmanaged) C++/CLI .NET Framework Managed C++ Native C++ Framework Classes Native C++ MFC Common Language Runtime (CLR) Operating System HHardware 09/09/2009 21
  • 22. C++/CLI Data Types 09/09/2009 Hadziq Fabroyir - Informatics ITS 22
  • 23. ITC1398 Introduction to Programming Chapter 3 23 Control Structures Three control structures Sequence structure Programs executed sequentially by default Selection structures if, if…else, switch Repetition structures while, do…while, for
  • 24. ITC1398 Introduction to Programming Chapter 3 24 if Selection Statement Choose among alternative courses of action Pseudocode example If student’s grade is greater than or equal to 60 print “Passed” If the condition is true Print statement executes, program continues to next statement If the condition is false Print statement ignored, program continues
  • 25. Activity Diagram 09/09/2009 Hadziq Fabroyir - Informatics ITS 25
  • 26. ITC1398 Introduction to Programming Chapter 3 26 if Selection Statement Translation into C++ if ( grade >= 60 ) cout << "Passed"; Any expression can be used as the condition If it evaluates to zero, it is treated as false If it evaluates to non-zero, it is treated as true
  • 27. ITC1398 Introduction to Programming Chapter 3 27 if…else Double-Selection Statement if Performs action if condition true if…else Performs one action if condition is true, a different action if it is false Pseudocode If student’s grade is greater than or equal to 60 print “Passed”Else print “Failed” C++ code if ( grade >= 60 ) cout << "Passed";else cout << "Failed";
  • 28. Activity Diagram 09/09/2009 Hadziq Fabroyir - Informatics ITS 28
  • 29. ITC1398 Introduction to Programming Chapter 3 29 if…else Double-Selection Statement Ternary conditional operator (?:) Three arguments (condition, value if true, value if false) Code could be written: cout << ( grade >= 60 ? “Passed” : “Failed” ); Condition Value if true Value if false
  • 30. ITC1398 Introduction to Programming Chapter 3 30 if…else Double-Selection Statement Nested if…else statements One inside another, test for multiple cases Once a condition met, other statements are skipped Example If student’s grade is greater than or equal to 90 Print “A” Else If student’s grade is greater than or equal to 80 Print “B” Else If student’s grade is greater than or equal to 70 Print “C” Else If student’s grade is greater than or equal to 60 Print “D” Else Print “F”
  • 31. ITC1398 Introduction to Programming Chapter 3 31 if…else Double-Selection Statement Nested if…else statements (Cont.) Written In C++ if ( studentGrade >= 90 ) cout << "A";elseif (studentGrade >= 80 ) cout << "B";elseif (studentGrade >= 70 ) cout << "C"; elseif ( studentGrade >= 60 ) cout << "D";else cout << "F";
  • 32. while Repetition Statement A repetition statement (also called a looping statement or a loop) allows the programmer to specify that a program should repeat an action while some condition remains true. The pseudocode statement While there are more items on my shopping list Purchase next item and cross it off my list 09/09/2009 Hadziq Fabroyir - Informatics ITS 32
  • 33. for Repetition Statement 09/09/2009 Hadziq Fabroyir - Informatics ITS 33
  • 34. do …while Repetition Statement do { statement } while ( condition ); 09/09/2009 Hadziq Fabroyir - Informatics ITS 34
  • 35. switch Multiple-Selection Statement 09/09/2009 Hadziq Fabroyir - Informatics ITS 35
  • 36. For your practice … Lab Session I (Ahad, 19.00-21.00) 4.14 5.20 6.27 Lab Session II (Senin, 19.00-21.00) 4.35 5.12 6.30 09/09/2009 Hadziq Fabroyir - Informatics ITS 36
  • 37. ☺~ Next: OOP using C++ ~☺ [ 37 ] Hadziq Fabroyir - Informatics ITS 09/09/2009