SlideShare a Scribd company logo
Programming with Sikander
CorporateTrainer: C, Modern C++, Python, Linux System Prog
Video : https://youtu.be/cSH1dm9dXHM
 Applying Range Based For loop –
 Fixed Size Arrays
 Vector and List
 Array
2
Programming with Sikander : Modern C++: Range Based For Loop
 Executes a for loop over a range
 Used as a more readable equivalent to the
traditional for loop operating over a range of
values, such as all elements in a container.
3
Syntax :
for ( for-range-declaration : expression )
{
statement
}
Programming with Sikander : Modern C++: Range Based For Loop
4
Programming with Sikander : Modern C++: Range Based For Loop
5
Programming with Sikander : Modern C++: Range Based For Loop
6
Programming with Sikander : Modern C++: Range Based For Loop
7
Programming with Sikander : Modern C++: Range Based For Loop
8
Programming with Sikander : Modern C++: Range Based For Loop
 Can modify the elements of container.
 Does not make copy of elements.
 Is faster.
9
Programming with Sikander : Modern C++: Range Based For Loop
10
Programming with Sikander : Modern C++: Range Based For Loop
 Cannot be applied on pointers.
11
Programming with Sikander : Modern C++: Range Based For Loop
12
Programming with Sikander : Modern C++: Range Based For Loop
 Cannot traverse a part of list.
 Cannot traverse in reverse order.
 Cannot be applied to pointers.
13
Programming with Sikander : Modern C++: Range Based For Loop
14
Programming with Sikander : Modern C++: Range Based For Loop
15
Programming with Sikander : Modern C++: Range Based For Loop
 Range based for loop can be applied on
containers to simplify the programs.
 It can be applied on sequence and associative
containers.
 It can be applied for all containers for which we
can apply begin and end algorithm or contains
begin and end members functions
 Cannot be used to traverse part of list.
 Cannot be applied on pointers.
16
Programming with Sikander : Modern C++: Range Based For Loop
Modern_CPP-Range-Based For Loop.pptx

More Related Content

PPTX
Embedded C.pptx
PDF
Modern_cpp_auto.pdf
PPTX
COMPILER DESIGN
PPTX
Sonarqube
PPTX
compiler construction tool in computer science .
PDF
Introduction to the LLVM Compiler System
PDF
Code coverage & tools
PDF
Improving Pharo Snapshots
Embedded C.pptx
Modern_cpp_auto.pdf
COMPILER DESIGN
Sonarqube
compiler construction tool in computer science .
Introduction to the LLVM Compiler System
Code coverage & tools
Improving Pharo Snapshots

What's hot (20)

PPTX
Python Programming | JNTUA | UNIT 2 | Case Study |
PPTX
Golang (Go Programming Language)
PDF
PDF
Top C Language Interview Questions and Answer
PPT
1. over view and history of c
PDF
Core_Java_with_SCJP_OCJP_Notes_By_Durga.pdf
PPTX
Programming Languages: Trends for 2021
PPTX
compiler and their types
PPTX
SonarQube - The leading platform for Continuous Code Quality
PDF
UVM: Basic Sequences
PPTX
SonarQube Presentation.pptx
PPTX
C programming orientation
PDF
Rust for professionals.pdf
PPTX
Static Analysis with Sonarlint
PPT
Unit 1 python (2021 r)
PPTX
page replacement.pptx
PDF
AD-IP-JESD204 JESD204B Interface Framework
PDF
Soc - Intro, Design Aspects, HLS, TLM
PPTX
Rust programming-language
PDF
SOLID Principle & Design Pattern.pdf
Python Programming | JNTUA | UNIT 2 | Case Study |
Golang (Go Programming Language)
Top C Language Interview Questions and Answer
1. over view and history of c
Core_Java_with_SCJP_OCJP_Notes_By_Durga.pdf
Programming Languages: Trends for 2021
compiler and their types
SonarQube - The leading platform for Continuous Code Quality
UVM: Basic Sequences
SonarQube Presentation.pptx
C programming orientation
Rust for professionals.pdf
Static Analysis with Sonarlint
Unit 1 python (2021 r)
page replacement.pptx
AD-IP-JESD204 JESD204B Interface Framework
Soc - Intro, Design Aspects, HLS, TLM
Rust programming-language
SOLID Principle & Design Pattern.pdf
Ad

Similar to Modern_CPP-Range-Based For Loop.pptx (20)

PPTX
C++ 11 range-based for loop
PPTX
Assignment of pseudo code
PPTX
3.01.Lists.pptx
PPTX
Chap_________________1_Introduction.pptx
PPTX
12-Lec - Repetition For Loop.pptx
PPTX
C_BASICS FOR C PROGRAMMER WITH SRIVATHS P
PDF
c++ practical Digvajiya collage Rajnandgaon
PPT
Database structure Structures Link list and trees and Recurison complete
PPTX
Standard template library
PPTX
Data Structures in C
PPTX
Data structures and Algorithm analysis_Lecture 2.pptx
PDF
Data Structures & Algorithm design using C
PPTX
Introduction_to_Cpp_with_Images_and_Activity.pptx
PPTX
lab-8 (1).pptx
PDF
Data Structures 01
PDF
Tech Talks @NSU: DLang: возможности языка и его применение
PPTX
Object Oriented Design and Programming Unit-05
PDF
Acm aleppo cpc training introduction 1
PPT
Basics of cpp
PPT
1.1 introduction to Data Structures.ppt
C++ 11 range-based for loop
Assignment of pseudo code
3.01.Lists.pptx
Chap_________________1_Introduction.pptx
12-Lec - Repetition For Loop.pptx
C_BASICS FOR C PROGRAMMER WITH SRIVATHS P
c++ practical Digvajiya collage Rajnandgaon
Database structure Structures Link list and trees and Recurison complete
Standard template library
Data Structures in C
Data structures and Algorithm analysis_Lecture 2.pptx
Data Structures & Algorithm design using C
Introduction_to_Cpp_with_Images_and_Activity.pptx
lab-8 (1).pptx
Data Structures 01
Tech Talks @NSU: DLang: возможности языка и его применение
Object Oriented Design and Programming Unit-05
Acm aleppo cpc training introduction 1
Basics of cpp
1.1 introduction to Data Structures.ppt
Ad

More from Mohammed Sikander (20)

PDF
STL Containers in C++ : Sequence Container : Vector
PPTX
Strings in C - covers string functions
PDF
Smart Pointers, Modern Memory Management Techniques
PDF
Multithreading_in_C++ - std::thread, race condition
PDF
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
PDF
Operator Overloading in C++
PDF
Python_Regular Expression
PPTX
Python Functions
PPTX
Python dictionary
PDF
Python exception handling
PDF
Python tuple
PDF
Python strings
PDF
Python set
PDF
Python list
PDF
Python Flow Control
PDF
Introduction to Python
PPTX
Pointer basics
PPTX
PPTX
File management
STL Containers in C++ : Sequence Container : Vector
Strings in C - covers string functions
Smart Pointers, Modern Memory Management Techniques
Multithreading_in_C++ - std::thread, race condition
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Operator Overloading in C++
Python_Regular Expression
Python Functions
Python dictionary
Python exception handling
Python tuple
Python strings
Python set
Python list
Python Flow Control
Introduction to Python
Pointer basics
File management

Recently uploaded (20)

PDF
Sports Quiz easy sports quiz sports quiz
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
Computing-Curriculum for Schools in Ghana
PDF
Basic Mud Logging Guide for educational purpose
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Cell Structure & Organelles in detailed.
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Institutional Correction lecture only . . .
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Supply Chain Operations Speaking Notes -ICLT Program
Sports Quiz easy sports quiz sports quiz
O5-L3 Freight Transport Ops (International) V1.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
2.FourierTransform-ShortQuestionswithAnswers.pdf
RMMM.pdf make it easy to upload and study
Computing-Curriculum for Schools in Ghana
Basic Mud Logging Guide for educational purpose
102 student loan defaulters named and shamed – Is someone you know on the list?
Cell Structure & Organelles in detailed.
Complications of Minimal Access Surgery at WLH
Institutional Correction lecture only . . .
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Microbial diseases, their pathogenesis and prophylaxis
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
VCE English Exam - Section C Student Revision Booklet
Supply Chain Operations Speaking Notes -ICLT Program

Modern_CPP-Range-Based For Loop.pptx

  • 1. Programming with Sikander CorporateTrainer: C, Modern C++, Python, Linux System Prog Video : https://youtu.be/cSH1dm9dXHM
  • 2.  Applying Range Based For loop –  Fixed Size Arrays  Vector and List  Array 2 Programming with Sikander : Modern C++: Range Based For Loop
  • 3.  Executes a for loop over a range  Used as a more readable equivalent to the traditional for loop operating over a range of values, such as all elements in a container. 3 Syntax : for ( for-range-declaration : expression ) { statement } Programming with Sikander : Modern C++: Range Based For Loop
  • 4. 4 Programming with Sikander : Modern C++: Range Based For Loop
  • 5. 5 Programming with Sikander : Modern C++: Range Based For Loop
  • 6. 6 Programming with Sikander : Modern C++: Range Based For Loop
  • 7. 7 Programming with Sikander : Modern C++: Range Based For Loop
  • 8. 8 Programming with Sikander : Modern C++: Range Based For Loop
  • 9.  Can modify the elements of container.  Does not make copy of elements.  Is faster. 9 Programming with Sikander : Modern C++: Range Based For Loop
  • 10. 10 Programming with Sikander : Modern C++: Range Based For Loop
  • 11.  Cannot be applied on pointers. 11 Programming with Sikander : Modern C++: Range Based For Loop
  • 12. 12 Programming with Sikander : Modern C++: Range Based For Loop
  • 13.  Cannot traverse a part of list.  Cannot traverse in reverse order.  Cannot be applied to pointers. 13 Programming with Sikander : Modern C++: Range Based For Loop
  • 14. 14 Programming with Sikander : Modern C++: Range Based For Loop
  • 15. 15 Programming with Sikander : Modern C++: Range Based For Loop
  • 16.  Range based for loop can be applied on containers to simplify the programs.  It can be applied on sequence and associative containers.  It can be applied for all containers for which we can apply begin and end algorithm or contains begin and end members functions  Cannot be used to traverse part of list.  Cannot be applied on pointers. 16 Programming with Sikander : Modern C++: Range Based For Loop

Editor's Notes

  • #2: https://www.ibm.com/docs/en/i/7.3?topic=specifiers-auto-type-specifier-c11
  • #5: #include <iostream> using namespace std; int main() { int arr[5] = {5 , 10 , 12, 20 , 40}; for(int i : arr) cout << i << endl; return 0; }
  • #6: #include <iostream> using namespace std; int main() { double arr[5] = {5.2 , 10.5 , 1.2, 2.3 , 4.5}; for(double i : arr) cout << i << endl; return 0; }
  • #7: #include <iostream> using namespace std; int main() { double arr[5] = {5.2 , 10.5 , 1.2, 2.3 , 4.5}; for(double i : arr) cout << i << endl; return 0; }
  • #8: #include <iostream> using namespace std; int main() { int arr[5] = {5 , 10 , 12, 20 , 40}; for(int ele : arr) ele = ele + 2; for(int ele : arr) cout << ele << endl; return 0; }
  • #9: #include <iostream> using namespace std; int main() { int arr[5] = {5 , 10 , 12, 20 , 40}; for(int &ele : arr) ele = ele + 2; for(int ele : arr) cout << ele << endl; return 0; }
  • #10: int main() { int arr[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; for(int &ele : arr ) { ele = ele + x; } for( const int &ele : arr ) { cout << ele << " "; } return 0; }
  • #11: #include <iostream> using namespace std; int main() { int iarr[5] = { 1, 2, 3, 4, 5}; double darr[5] = {5.2 , 10.5 , 1.2, 2.3 , 4.5}; for(const auto &ele : iarr ) { cout << ele << " "; } cout << endl; for(const auto &ele : darr ) { cout << ele << " "; } return 0; }
  • #12: #include <iostream> #include <vector> using namespace std; void printArray(int arr[]) { for (const auto &ele : arr) cout << ele << ' '; cout << endl; } int main() { int arr[] = {0, 7, 2, 3, 4, 5}; for (const auto &ele : arr) cout << ele << ' '; cout << endl; printArray ( arr ); }
  • #13: #include <iostream> #include <vector> #include <list> using namespace std; int main() { std::vector<int> v = {0, 7, 2, 3, 4, 5}; for (const auto &ele : v) std::cout << ele << ' '; cout << endl; std::list<int> lst = {8, 6, 4, 2, 1}; for (const auto &ele : lst) std::cout << ele << ' '; }
  • #15: #include <iostream> #include <vector> #include <list> using namespace std; void printVector(vector <int> &v) { cout <<"Elements of Vector in Function \n"; for (const auto &ele : v) cout << ele << ' '; cout << endl; } int main() { vector<int> v = {0, 7, 2, 3, 4, 5}; cout <<"Elements of Vector in Main \n"; for (const auto &ele : v) cout << ele << ' '; cout << endl; printVector ( v ); }
  • #16: #include <iostream> #include <vector> #include <map> using namespace std; class Base { public : Base() { } Base(const Base &b) { cout <<"Base Copy Constructor \n"; } virtual void display() { cout <<"Base Display \n"; } }; class Derived : public Base { public : Derived(){} Derived(const Derived &b) : Base(b) { cout <<"Derived Copy Constructor \n"; } virtual void display() { cout <<"Derived Display \n"; } }; int main() { vector < Base *> v; v.push_back((new Base())); v.push_back((new Base())); v.push_back((new Derived())); v.push_back((new Derived())); for(Base *ele : v) ele->display(); }