1 Introduction To C++ Programming Ahmad Baryal Saba Institute of Higher Education Computer Science Faculty Sep 10, 2024
2 Table of contents ï‚§ C++ Introduction ï‚§ Object-oriented and procedural programming ï‚§ Why use C++? ï‚§ Difference b/w C and C++ ï‚§ Getting started with C++ ï‚§ First program!
3 C++ Introduction ï‚´ C++ is a cross-platform language that can be used to create high- performance applications. ï‚´ C++ was developed by Bjarne Stroustrup, as an extension to the C language. ï‚´ C++ gives programmers a high level of control over system resources and memory. ï‚´ The language was updated 4 major times in 2011, 2014, 2017, and 2020 to C++11, C++14, C++17, C++20
4 Object-Oriented Programming ï‚´ Object-oriented programming (OOP) is a programming paradigm that uses objects, which are instances of classes, to design and structure software. OOP focuses on organizing data (attributes or properties) and the functions (methods) that operate on that data into reusable and self-contained units. ï‚´ Procedural programming is a programming approach where tasks are solved by breaking them down into a sequence of step-by-step procedures or functions.
5 Why Use C++ ? ï‚´ C++ is one of the world's most popular programming languages. ï‚´ C++ can be found in today's operating systems, Graphical User Interfaces, and embedded systems. ï‚´ C++ is an object-oriented programming language which gives a clear structure to programs and allows code to be reused, lowering development costs. ï‚´ C++ is portable and can be used to develop applications that can be adapted to multiple platforms. ï‚´ C++ is fun and easy to learn! ï‚´ As C++ is close to C, C# and Java, it makes it easy for programmers to switch to C++ or vice versa.
6 Difference between C and C++ ï‚´ C++ was developed as an extension of C, and both languages have almost the same syntax. ï‚´ The main difference between C and C++ is that C++ support classes and objects, while C does not. ï‚´ C is more like writing step-by-step instructions, while C++ adds a layer of organization and automation to make coding more efficient and manageable.
7 C++ Getting Started  To start using C++, you need two things: • A text editor, like Notepad, to write C++ code • A compiler, like GCC, to translate the C++ code into a language that the computer will understand  There are many text course and compilers to choose from. In this course, we will use an IDE (Code::Blocks or VS Code).
8 C++ Install IDE ï‚´ An IDE (Integrated Development Environment) is used to edit AND compile the code. ï‚´ Popular IDE's include Code::Blocks, Eclipse, and Visual Studio. These are all free, and they can be used to both edit and debug C++ code. ï‚´ Note: Web-based IDE's can work as well, but functionality is limited. ï‚´ We will use Code::Blocks in our tutorial, which we believe is a good place to start. ï‚´ You can find the latest version of Codeblocks at http://www.codeblocks.org/. Download the mingw-setup.exe file, which will install the text editor with a compiler.
9 C++ Quickstart ï‚´ Open Codeblocks and go to File > New > Empty File. ï‚´ Write the following C++ code and save the file as myfirstprogram.cpp (File > Save File as):
10 C++ Quickstart ï‚´ In Codeblocks, it looks like this: ï‚´ The, go to Build>Build and Run to run(execute) the program.
11 C++ Syntax Line 1: #include <iostream> is a header file library that lets us work with input and output objects, such as cout (used in line 5). Header files add functionality to C++ programs. Line 2: using namespace std means that we can use names for objects and variables from the standard library. Line 3: A blank line. C++ ignores white space. But we use it to make the code more readable. Line 4: Another thing that always appear in a C++ program, is int main(). This is called a function. Any code inside its curly brackets {} will be executed.
12 C++ Syntax Line 5: cout (pronounced "see-out") is an object used together with the insertion operator (<<) to output/print text. In our example it will output "Hello World!". Note: Every C++ statement ends with a semicolon ;. Note: The body of int main() could also been written as: int main () { cout << "Hello World! "; return 0; } Remember: The compiler ignores white spaces. However, multiple lines makes the code more readable. Line 6: return 0 ends the main function. Line 7: Do not forget to add the closing curly bracket } to actually end the main function.
13 Omitting Namespace You might see some C++ programs that runs without the standard namespace library. The using namespace std line can be omitted and replaced with the std keyword, followed by the :: operator for some objects:
14 Any Questions?

Introduction to c++ programming language

  • 1.
    1 Introduction To C++Programming Ahmad Baryal Saba Institute of Higher Education Computer Science Faculty Sep 10, 2024
  • 2.
    2 Table ofcontents ï‚§ C++ Introduction ï‚§ Object-oriented and procedural programming ï‚§ Why use C++? ï‚§ Difference b/w C and C++ ï‚§ Getting started with C++ ï‚§ First program!
  • 3.
    3 C++ Introduction ï‚´C++ is a cross-platform language that can be used to create high- performance applications. ï‚´ C++ was developed by Bjarne Stroustrup, as an extension to the C language. ï‚´ C++ gives programmers a high level of control over system resources and memory. ï‚´ The language was updated 4 major times in 2011, 2014, 2017, and 2020 to C++11, C++14, C++17, C++20
  • 4.
    4 Object-Oriented Programming ï‚´Object-oriented programming (OOP) is a programming paradigm that uses objects, which are instances of classes, to design and structure software. OOP focuses on organizing data (attributes or properties) and the functions (methods) that operate on that data into reusable and self-contained units. ï‚´ Procedural programming is a programming approach where tasks are solved by breaking them down into a sequence of step-by-step procedures or functions.
  • 5.
    5 Why UseC++ ? ï‚´ C++ is one of the world's most popular programming languages. ï‚´ C++ can be found in today's operating systems, Graphical User Interfaces, and embedded systems. ï‚´ C++ is an object-oriented programming language which gives a clear structure to programs and allows code to be reused, lowering development costs. ï‚´ C++ is portable and can be used to develop applications that can be adapted to multiple platforms. ï‚´ C++ is fun and easy to learn! ï‚´ As C++ is close to C, C# and Java, it makes it easy for programmers to switch to C++ or vice versa.
  • 6.
    6 Difference betweenC and C++ ï‚´ C++ was developed as an extension of C, and both languages have almost the same syntax. ï‚´ The main difference between C and C++ is that C++ support classes and objects, while C does not. ï‚´ C is more like writing step-by-step instructions, while C++ adds a layer of organization and automation to make coding more efficient and manageable.
  • 7.
    7 C++ GettingStarted  To start using C++, you need two things: • A text editor, like Notepad, to write C++ code • A compiler, like GCC, to translate the C++ code into a language that the computer will understand  There are many text course and compilers to choose from. In this course, we will use an IDE (Code::Blocks or VS Code).
  • 8.
    8 C++ InstallIDE ï‚´ An IDE (Integrated Development Environment) is used to edit AND compile the code. ï‚´ Popular IDE's include Code::Blocks, Eclipse, and Visual Studio. These are all free, and they can be used to both edit and debug C++ code. ï‚´ Note: Web-based IDE's can work as well, but functionality is limited. ï‚´ We will use Code::Blocks in our tutorial, which we believe is a good place to start. ï‚´ You can find the latest version of Codeblocks at http://www.codeblocks.org/. Download the mingw-setup.exe file, which will install the text editor with a compiler.
  • 9.
    9 C++ Quickstart ï‚´Open Codeblocks and go to File > New > Empty File. ï‚´ Write the following C++ code and save the file as myfirstprogram.cpp (File > Save File as):
  • 10.
    10 C++ Quickstart ï‚´In Codeblocks, it looks like this: ï‚´ The, go to Build>Build and Run to run(execute) the program.
  • 11.
    11 C++ Syntax Line1: #include <iostream> is a header file library that lets us work with input and output objects, such as cout (used in line 5). Header files add functionality to C++ programs. Line 2: using namespace std means that we can use names for objects and variables from the standard library. Line 3: A blank line. C++ ignores white space. But we use it to make the code more readable. Line 4: Another thing that always appear in a C++ program, is int main(). This is called a function. Any code inside its curly brackets {} will be executed.
  • 12.
    12 C++ Syntax Line5: cout (pronounced "see-out") is an object used together with the insertion operator (<<) to output/print text. In our example it will output "Hello World!". Note: Every C++ statement ends with a semicolon ;. Note: The body of int main() could also been written as: int main () { cout << "Hello World! "; return 0; } Remember: The compiler ignores white spaces. However, multiple lines makes the code more readable. Line 6: return 0 ends the main function. Line 7: Do not forget to add the closing curly bracket } to actually end the main function.
  • 13.
    13 Omitting Namespace Youmight see some C++ programs that runs without the standard namespace library. The using namespace std line can be omitted and replaced with the std keyword, followed by the :: operator for some objects:
  • 14.