{"id":26708,"date":"2021-03-24T14:43:30","date_gmt":"2021-03-24T09:13:30","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/"},"modified":"2022-10-21T11:29:32","modified_gmt":"2022-10-21T05:59:32","slug":"cpp-tutorial","status":"publish","type":"post","link":"https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/","title":{"rendered":"C++ Tutorial for Beginners"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"history-of-c\"><strong>History of C++<\/strong><\/h2>\n\n\n\n<p>C++ evolved from C, which earlier from two previous programming languages, BCPL and B language.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>BCPL:<\/strong><\/li>\n<\/ol>\n\n\n\n<p>BCPL was developed in 1967 by Martin Richard as a language for writing operating system software and compilers.<\/p>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>B language:<\/strong><\/li>\n<\/ol>\n\n\n\n<p>B language was developed by Ken Thompson.<\/p>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>C language<\/strong><strong>:<\/strong><\/li>\n<\/ol>\n\n\n\n<p>C language evolved from B language, else a programming language designed by Dennis Ritchie in AT and T laboratories in 1972.<\/p>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>C++:<\/strong><\/li>\n<\/ol>\n\n\n\n<p>An extension of C, was developed by Bjarne Stroustrup in the early 1980s at Bell laboratories.<\/p>\n\n\n\n    <div class=\"courses-cta-container\">\n        <div class=\"courses-cta-card\">\n            <div class=\"courses-cta-header\">\n                <div class=\"courses-learn-icon\"><\/div>\n                <span class=\"courses-learn-text\">Academy Pro<\/span>\n            <\/div>\n            <p class=\"courses-cta-title\">\n                <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/learn-c-programming-for-beginners-to-advanced\" class=\"courses-cta-title-link\">C++ Programming Course<\/a>\n            <\/p>\n            <p class=\"courses-cta-description\">Master key C++ programming concepts like variables, functions, OOP, and control structures. Build real-world projects such as a banking system and grade management tool.<\/p>\n            <div class=\"courses-cta-stats\">\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-user-icon\"><\/div>\n                    <span>Beginner to Advanced Level<\/span>\n                <\/div>\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-star-icon\"><\/div>\n                    <span>8.1 hrs<\/span>\n                <\/div>\n            <\/div>\n            <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/learn-c-programming-for-beginners-to-advanced\" class=\"courses-cta-button\">\n                Start Free Trial\n                <div class=\"courses-arrow-icon\"><\/div>\n            <\/a>\n        <\/div>\n    <\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-meant-by-a-programming-language\">What is meant by a programming language?<\/h2>\n\n\n\n<p>A programming language is a set of rules that provides a way of talking with the computer about what operation to be performed.<\/p>\n\n\n\n<p>A programming language is a set of rules for communicating algorithms.<\/p>\n\n\n\n<p>A programming language is a notational system for describing competition in machine in readable and human readable form.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-a-compiler\">What is a Compiler?<\/h2>\n\n\n\n<p>Compiler scans the whole source code and translates it into machine readable form.<\/p>\n\n\n\n<p>Execution time required is less.<\/p>\n\n\n\n<p>We can save the file after the competition.<\/p>\n\n\n\n<p>As the whole code is compiled at once so no need for further compiling.<\/p>\n\n\n\n<p>Compiler generates the error code after scanning the whole code.<\/p>\n\n\n\n<p>Compiler is not so good for debugging.<\/p>\n\n\n\n<p>CPU utilization is more in the compiler.<\/p>\n\n\n\n<p>It is used in C, C++ languages.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-an-interpreter\">What is an interpreter?<\/h2>\n\n\n\n<p>Interpreter translates the whole code line by line.<\/p>\n\n\n\n<p>Interpreter required execution time is more.<\/p>\n\n\n\n<p>Interpreter does not save the file after interpretation.<\/p>\n\n\n\n<p>Each line of the code should be compiled. It means the interpreter compiles the whole code line by line.<\/p>\n\n\n\n<p>It continues to translate until the error is found.<\/p>\n\n\n\n<p>It is good for debugging.<\/p>\n\n\n\n<p>CPU utilization is less.&nbsp;<\/p>\n\n\n\n<p>It is used in python, java.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.mygreatlearning.com\/blog\/c-interview-questions\/\" target=\"_blank\" rel=\"noreferrer noopener\">Also read C interview articles.<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-an-object-oriented-programming-oop\">What is an Object oriented programming (OOP):-<\/h2>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;C++ is Object Oriented programming (OOP) language, it allows us to divide a complex code into smaller sets by using objects. It gives a clear structure to the program and allows code to be reused. There are six features of OOPs: Classes and objects, Message and Methods, Encapsulation, Inheritance, Polymorphism, Abstraction. The four major pillar of OOP are:&nbsp;<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Encapsulation<\/li>\n\n\n\n<li>&nbsp;Inheritance<\/li>\n\n\n\n<li>Polymorphism<\/li>\n\n\n\n<li>Abstraction.<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Four pillars of OOPs: -<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Encapsulation: -<\/li>\n<\/ol>\n\n\n\n<p>Data is very important so we need to protect that data. Such type of protection to data is known as encapsulation so we can say that encapsulation is the packing of data and functions.<\/p>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Inheritance: -<\/li>\n<\/ol>\n\n\n\n<p>One object acquires the property of another object through relationships. The relationship that is simulated is known as inheritance.<\/p>\n\n\n\n<p>For example-<\/p>\n\n\n\n<p>Children inherit some features of their parents.<\/p>\n\n\n\n<p>Teacher teaches some good things to students.<\/p>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Polymorphism: -<\/li>\n<\/ol>\n\n\n\n<p>Polymorphism means \u201cmany forms\u201d but in the terms of programming language polymorphism&nbsp; is the ability to use an operator or method in different ways to make end users use the software on different platforms.<\/p>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>Abstraction: -<\/li>\n<\/ol>\n\n\n\n<p>Selecting a few attributes from the rest is called abstraction so we can say that the abstraction hides the unnecessary data and pops up the important data.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Advantages of OOP: -<\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\">\n<li>To modularize software development, just like other engineering disciplines.<\/li>\n\n\n\n<li>To make software projects more manageable and predictable.<\/li>\n\n\n\n<li>For letter maintainability, since software maintenance costs were then the development costs.<\/li>\n\n\n\n<li>For reusing code and preventing reinvention of the wheel every time.<\/li>\n<\/ol>\n\n\n\n<p>Object-Oriented Programming finds a lot of application in the real business system. The various place where OOP is required is: -<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Database management system.<\/li>\n\n\n\n<li>Intelligence system.<\/li>\n\n\n\n<li>Pattern recognition system.<\/li>\n\n\n\n<li>Image processing system.<\/li>\n\n\n\n<li>Parallel computing.<\/li>\n\n\n\n<li>Mobile computing.<\/li>\n\n\n\n<li>Data security system.<\/li>\n\n\n\n<li>Features of OOP: -<\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Emphasis on data rather on procedure.<\/li>\n\n\n\n<li>Programs are divided into what are known as objects.<\/li>\n\n\n\n<li>Functions that operate on data of an object are laid together in a data structure.<\/li>\n\n\n\n<li>Objects may communicate with each other through functions.<\/li>\n\n\n\n<li>New data and functions can be added easily whenever necessary.<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>How to write a basic C++ code: -<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The # include is a preprocessor directive.<\/li>\n\n\n\n<li>Pre-processor directive begin with a # sign<\/li>\n\n\n\n<li>They are processed before compilation.<\/li>\n\n\n\n<li>The directive \u201c# include&lt;iostream&gt;\u201d tells the pre-processor to include the \u201ciostream\u201d header file to support I\/O operations.<\/li>\n\n\n\n<li>By using namespace std (\u201c) declares std as the default namespace used in this program. The names count and end which is used in the program belong to std namespace.<\/li>\n\n\n\n<li>These two lines shall be present in all our programs.<\/li>\n\n\n\n<li>\u201ccount\u201d refers to the standard output (or the console output).<\/li>\n\n\n\n<li>The symbol &lt;&lt; is called the Stream insertion operator (or put to operator), which is used to put the console.<\/li>\n\n\n\n<li>\u201cend l\u201d denotes the end of line or new line which is put to the console to string the error to the beginning of the new line.<\/li>\n\n\n\n<li>&nbsp;\u201creturn 0;\u201d Terminates the main( ) function and returns a value 0 to the operating system.<\/li>\n<\/ol>\n\n\n\n<p>Example : -<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream&gt;\nusing namespace std;\nint main()\n{\n     cout&lt;&lt;\"Hello world\";\n     return 0;\n}\n<\/code><\/pre>\n\n\n\n<p>Basic code of C++&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;#include&lt;iostream&gt;<\/p>\n\n\n\n<p>using namespace std;<\/p>\n\n\n\n<p>int main()<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&lt;&lt;\"Hello world\";<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 0;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>This is the basic example of C++<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The C++ environment: -<\/li>\n\n\n\n<li>Editor: -<\/li>\n<\/ul>\n\n\n\n<p>The first phase of C++ environment, used to create program source code. It is where you type the program.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Pre-processor: -<\/li>\n<\/ul>\n\n\n\n<p>&nbsp;The second phase of C++ environment use to the programs executes automatically before the compiler's translation phase begins.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Compiler: -<\/li>\n<\/ul>\n\n\n\n<p>The third phase of C++ environment, used to compile source codes into machine language (object code file\/ binary format).<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Linker: -&nbsp;<\/li>\n<\/ul>\n\n\n\n<p>The fourth phase of C++ environment is to convert (.cc) file to an executable file(.c).<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>CPU: -<\/li>\n<\/ul>\n\n\n\n<p>T<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"the-integrated-development-environment-ide\">The Integrated Development Environment (IDE) : -<\/h2>\n\n\n\n<p>An IDE is a program that has the compiler, debugger and application building tools. You can create programs debugging without leaving the IDE.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Debugging: -<\/li>\n<\/ul>\n\n\n\n<p>BUG: -&nbsp;<\/p>\n\n\n\n<p>An error in a program can refer to anything that produces difficulty in program execution or compilation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"debugging\">Debugging: -<\/h2>\n\n\n\n<p>Looking for correcting errors or mistakes that cause your programs to behave unexpectable. It means debugging corrects the programming errors.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"types-of-errors\">Types of Errors:&nbsp;<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Syntax errors: -<\/li>\n<\/ol>\n\n\n\n<p>Syntax errors are mistakes caused by violating the grammar rules of C++.<\/p>\n\n\n\n<p>A program with no syntax errors may still not produce correct results.<\/p>\n\n\n\n<p>For example: - 2+3*5 and (2+3)*5 Both are syntactically correct expressions, but have different meanings.so if you use one of these expressions where you should use one of these expressions where you should use the other one, your program will produce incorrect results.<\/p>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Run-time error: -<\/li>\n<\/ol>\n\n\n\n<p>Run-time errors also called as Semantic or Smart errors are caused by input output rules during the execution of our programs.<\/p>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Logical error: -<\/li>\n<\/ol>\n\n\n\n<p>Logical errors are the most difficult errors to recognize and correct because the computer does not indicate those errors in your programs as it does with syntax and runtime errors.<\/p>\n\n\n\n<p>Your program may have appeared to have executed successfully, however; the answers may be completely wrong.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"difference-between-procedure-oriented-programming-pop-and-object-oriented-programming-oops\">Difference between Procedure Oriented Programming (POP) and Object-Oriented Programming (OOPs): -<\/h2>\n\n\n\n<p>Procedure Oriented Programming (POP): -<\/p>\n\n\n\n<p>1) In Procedure Oriented Programming, the program is divided into small parts known as function.<\/p>\n\n\n\n<p>2)Importance- In Procedure Oriented Programming, importance is not given to data but to functions.<\/p>\n\n\n\n<p>3)In Procedure Oriented Programming, the top to Down approach is taken.<\/p>\n\n\n\n<p>4) To add new data and function is not easy.<\/p>\n\n\n\n<p>5) In Procedure Oriented Programming, most functions use global data for sharing that can be accessed freely from function to function.<\/p>\n\n\n\n<p>6) Procedure Oriented Programming does not have any proper way for hiding data so it is less secure.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Object-Oriented Programming: -<\/li>\n<\/ul>\n\n\n\n<p>1) IN OOP, the program is divided into parts called objects.<\/p>\n\n\n\n<p>2)In OOP, importance is given to data rather than functions.<\/p>\n\n\n\n<p>3)In OOP bottom to up approach.<\/p>\n\n\n\n<p>4) OOP provides more functionality to add data.<\/p>\n\n\n\n<p>5)In OOP, data cannot move easily from function to function, it is kept public or private.<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6)OOP provides data hiding so it is more secure.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"advantages-and-disadvantages-of-pop\">Advantages and disadvantages of POP: -<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>A procedure -oriented programming language is one in which procedure or methods or functions are given more significations. Here, function calls another.<\/li>\n\n\n\n<li>There can be global variables and local variables in each function.<\/li>\n\n\n\n<li>In this language, the task is divided into smaller tasks or subtasks called as procedure or functions or methods.<\/li>\n\n\n\n<li>Any function can be called at any instant the global variable can be accessed by all functions. While the local variables are local to the corresponding function.<\/li>\n\n\n\n<li>A procedure-oriented programming language follows a top to bottom approach.<\/li>\n\n\n\n<li>Top-bottom approach refers to approaching a problem as a big task or as a whole. then dividing this task and then small tasks are written in defaults.<\/li>\n\n\n\n<li>The disadvantage of such type of programming is that it is difficult to trace which functions are using the data and also error correction is difficult.<\/li>\n\n\n\n<li>C programming language is an example of procedure-oriented language.<\/li>\n\n\n\n<li>Data hiding expansion of data is not possible in procedure -oriented programming.<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Object-oriented programming and Its Development: -<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Object-oriented programming as the name says gives more significance to objects which have data of the object that can be accessed by the functions. The function of one object can access the data of another object through the function of that object.<\/li>\n\n\n\n<li>Object-oriented programming uses a bottom-up approach; smaller tasks are first dealt in detail and gradually creating the entire huge system.<\/li>\n\n\n\n<li>C++ and java are examples of Object-oriented programming.<\/li>\n\n\n\n<li>Object-oriented programming, on other hand, given more important to data than procedure.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"c-terminology\">C++ Terminology: -<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Statement: - A programming statement performs a piece of programming action. It must be terminated by semicolon (;).<\/li>\n\n\n\n<li>Preprocessor Directive: - the #include is a preprocessor directive and not a programming statement. It begins with # It is processed before compiling the program. A preprocessor directive is not terminated with a semicolon.<\/li>\n\n\n\n<li>Block: - A block is a group of statements enclosed by braces. This group is treated as one single unit. This is one block in this program which contains the body of the main function. There is no need to put a semicolon after closing braces.<\/li>\n\n\n\n<li>Whitespace: - Blank, top, new line are collectively called whitespaces. Extra white space is ignored, that is, one whitespace area is needed to separate the tokens.<\/li>\n\n\n\n<li>Case sensitive: - C++ is case sensitive.&nbsp;<\/li>\n<\/ul>\n\n\n\n<p>For example: - HELLO is not Hello and not a hello.&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>DATA TYPES:<\/strong><\/li>\n<\/ul>\n\n\n\n<p>The data types in C++ are classified as User defined, Derived, Primitive type.&nbsp;&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Primitive data type: -<\/li>\n<\/ul>\n\n\n\n<p>Primitive data type have following data types:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Integer-int<\/li>\n\n\n\n<li>Character-char<\/li>\n\n\n\n<li>Floating value<\/li>\n\n\n\n<li>Floating -float<\/li>\n\n\n\n<li>double<\/li>\n<\/ol>\n\n\n\n<p>and&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Void<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Derived data type: -<\/li>\n<\/ul>\n\n\n\n<p>Derived data type includes the following data type:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Arrays<\/li>\n\n\n\n<li>Pointers<\/li>\n\n\n\n<li>References<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>User-defined: -<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Structure<\/li>\n\n\n\n<li>Union<\/li>\n\n\n\n<li>Classes<\/li>\n\n\n\n<li>Enumerations<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>POINTER<\/strong><\/li>\n<\/ul>\n\n\n\n<p>A pointer is a variable whose value is the address of another variable.<\/p>\n\n\n\n<p>A general from of pointer variable declaration is type<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; *var_name;<\/p>\n\n\n\n<p>Here, type is a pointer base type; it must be a valid C++ data type and var_name is a name of a pointer variable.<\/p>\n\n\n\n<p>For Example:<\/p>\n\n\n\n<p>int*ip;<\/p>\n\n\n\n<p>double*bp;<\/p>\n\n\n\n<p>float*fp;<\/p>\n\n\n\n<p>char*ch;<\/p>\n\n\n\n<p>&nbsp;&nbsp;Pointer can have a data type int, double, float, char etc.<\/p>\n\n\n\n<p>Code for pointer: -<\/p>\n\n\n\n<p>#include&lt;iostream&gt;<\/p>\n\n\n\n<p>Using namespace std;<\/p>\n\n\n\n<p>Int main ( )<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>Int var=20*ptr1;<\/p>\n\n\n\n<p>Ptr1=&amp;var;<\/p>\n\n\n\n<p>cout &lt;&lt; \u201cAddress of ptr\u201d;<\/p>\n\n\n\n<p>cout&lt;&lt;ptr1&lt;&lt;end1;<\/p>\n\n\n\n<p>cout&lt;&lt; \u201cValue of ptr\u201d &lt;&lt;*ptr&lt;&lt;end1;<\/p>\n\n\n\n<p>}&nbsp;<\/p>\n\n\n\n<p>Code 2: -<\/p>\n\n\n\n<p>#include&lt;iostream&gt;<\/p>\n\n\n\n<p>Using namespace std;<\/p>\n\n\n\n<p>int main()<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>int*ptr1, *ptr2, a, b, c;<\/p>\n\n\n\n<p>cout&lt;&lt; \u201center value of a and b\u201d;<\/p>\n\n\n\n<p>cin&gt;&gt;a&gt;&gt;b;<\/p>\n\n\n\n<p>ptr1=&amp;a;<\/p>\n\n\n\n<p>ptr2=&amp;b;<\/p>\n\n\n\n<p>c=*ptr1+*ptr2;<\/p>\n\n\n\n<p>cout&lt;&lt; \u201cAddition of pointer\u201d;<\/p>\n\n\n\n<p>cout&lt;&lt;c&lt;&lt;end1;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>COUNTER: -<\/strong><\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Counter variable that is incremented or decremented each time a loop<\/li>\n<\/ol>\n\n\n\n<p>repeats.<\/p>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Can be used to control execution of loop (loop control\/ variable).<\/li>\n\n\n\n<li>Must be initialized before entering lop.<\/li>\n\n\n\n<li>Must be incremented\/decremented either inside the loop in the loop test.<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Comments: -<\/li>\n<\/ul>\n\n\n\n<p>The compiler simply ignores comments when it translates the program into executable code.<\/p>\n\n\n\n<p>To identify a comment, C use opening \/*and closing *\/ comment taken.<\/p>\n\n\n\n<p>Comments can appear anywhere in a program.<\/p>\n\n\n\n<p>Comments are also found whenever it is necessary to explain a point about a code.<\/p>\n\n\n\n<p>Comments cannot be nested, that means comments can not have comments inside comments.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Single line comment<\/li>\n<\/ul>\n\n\n\n<p>Example=<\/p>\n\n\n\n<p>\/\/ main function starts the character\/\/<\/p>\n\n\n\n<p>This is an example of a single line comment.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Multiline Comment<\/li>\n<\/ul>\n\n\n\n<p>Example=<\/p>\n\n\n\n<p>\/* this program takes two integers and provides the sum to the user *\/<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This is an example of multiline comment<\/p>\n\n\n\n<p>Comments are required to make the program more readable and understandable if anyone analyzes the code.<\/p>\n\n\n\n<p>#include&lt;iostream&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;using namespace std;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int main()<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&lt;&lt;\"Hello world\";<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 0;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Desirable program characteristic: =<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Clarity= the program should be written clearly<\/li>\n\n\n\n<li>Accuracy = The calculation should be accurate.<\/li>\n\n\n\n<li>Simplicity = The program should be clear.<\/li>\n\n\n\n<li>Efficiency = Execution speed and efficient memory utilization are the important ingredients of efficiency.&nbsp;&nbsp;<\/li>\n\n\n\n<li>Modularity = The program should be broken into small modules in order to clarity and accuracy of the program is known as modularity.&nbsp;<\/li>\n\n\n\n<li>Generality = the program should generate a re enable limit.<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Character set: -<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Character set is the set of character<\/li>\n\n\n\n<li>This character is used to form the word, numbers and expression.<\/li>\n\n\n\n<li>The characters are classified into following categories.<\/li>\n\n\n\n<li>Letter:&nbsp; Uppercase- A, B, C<\/li>\n<\/ol>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Lower case- a, b, c<\/p>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Digital: decimal digits 0 to 9<\/li>\n\n\n\n<li>Special Character:&nbsp; ,(comma), &nbsp; &nbsp; &nbsp; ;(semicolon) , &nbsp; : (colon),&nbsp; &amp;(ampersand),&nbsp; # (number line) etc.<\/li>\n\n\n\n<li>White space: Blank space.<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>TOKEN:<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Smallest individual units are known as tokens.<\/li>\n\n\n\n<li>There are six type of the token<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Keyword<\/li>\n\n\n\n<li>Identifiers<\/li>\n\n\n\n<li>Constants<\/li>\n\n\n\n<li>String<\/li>\n\n\n\n<li>Special symbols&nbsp;<\/li>\n\n\n\n<li>Operators<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Keywords<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Every word is classified as either keyword or identifier\u2019<\/li>\n\n\n\n<li>All keyword have fixed meaning and can change its meanings<\/li>\n\n\n\n<li>Keywords serve as a basic building for a program statement, ANSIC supports 32 keywords.<\/li>\n\n\n\n<li>Ex. Int. float, double, state, auto, continued, goto, short, long etc. are the keyword.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Auto<\/td><td>Int<\/td><td>Return<\/td><td>Long&nbsp;<\/td><\/tr><tr><td>Break<\/td><td>Double<\/td><td>Signed<\/td><td>Static<\/td><\/tr><tr><td>Case<\/td><td>Switch<\/td><td>Void<\/td><td>While<\/td><\/tr><tr><td>Char<\/td><td>Resister<\/td><td>Short<\/td><td>Unsigned<\/td><\/tr><tr><td>Const<\/td><td>Go to<\/td><td>Anum<\/td><td>Stract<\/td><\/tr><tr><td>Continue<\/td><td>If<\/td><td>Extern<\/td><td>Type of<\/td><\/tr><tr><td>Default<\/td><td>Float<\/td><td>Size of<\/td><td>Union<\/td><\/tr><tr><td>Do<\/td><td>Else<\/td><td>For<\/td><td><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Identifiers: -<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Identifiers refer to the name of variables, function, arrays.<\/li>\n\n\n\n<li>There are user defined names and consist of sequences of letters and digits.<\/li>\n\n\n\n<li>Both uppercase and lowercase letters are permitted to make the identifier but generally lowercase letters are used to make the variable.<\/li>\n<\/ol>\n\n\n\n<p>Rule for identifiers.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>First character must be alphabet<\/li>\n\n\n\n<li>Must not contain white space.<\/li>\n\n\n\n<li>Only the first 31 characters are significant.<\/li>\n\n\n\n<li>Cannot use keyword as an identifier.<\/li>\n<\/ol>\n\n\n\n<p>Mantissa (\u2018 \u2019) (\u201c&nbsp; \u201d)<\/p>\n\n\n\n<p>And exponential &nbsp;<\/p>\n\n\n\n<p>Decimal Octal&nbsp; &nbsp; Hexadecimal<\/p>\n\n\n\n<p>o-9&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0-7&nbsp; &nbsp; &nbsp; &nbsp; 0-9<\/p>\n\n\n\n<p>+, - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A-F<\/p>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Integer constant:<\/li>\n<\/ul>\n\n\n\n<p>An integer constant refers to a sequence of digits.<\/p>\n\n\n\n<p>There are three types of integer constants.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Decimal integer<\/li>\n\n\n\n<li>Octal integer<\/li>\n\n\n\n<li>Hexadecimal<\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Decimal integer:<\/li>\n<\/ol>\n\n\n\n<p>It consists of 0-9 digits, preceded by on optional -or+ sign.<\/p>\n\n\n\n<p>Valid examples of decimal integers are: 123, -321, 0, 6554321, +78.<\/p>\n\n\n\n<p>Embedded spaces, comma and nondigital character are not permitted between digits.<\/p>\n\n\n\n<p>15&nbsp; 750,&nbsp; &nbsp; &nbsp; 20,000,&nbsp; &nbsp; $100 are illegal.<\/p>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Octal integer&nbsp;<\/li>\n<\/ol>\n\n\n\n<p>An octal integer consists of digits 0-7 with a leading 0.<\/p>\n\n\n\n<p>Example; 037,0,0435,0551.<\/p>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Hexadecimal<\/li>\n<\/ol>\n\n\n\n<p>A sequence of digits preceded by ox or OX is considered as hexadecimal integer.<\/p>\n\n\n\n<p>Hexadecimal integers include 0 to 9 digits and A and F letters.<\/p>\n\n\n\n<p>Example \u2013 ox9, OX9F, oxbc etc. are valid.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Trigraphs&nbsp;<\/li>\n<\/ul>\n\n\n\n<p>A few characters have an alternative representation, called a trigraph sequence. A trigraph is a three-character sequence that represents a single character and the sequence always starts with two question marks. Trigraphs are expanded anywhere they appear, including within string literals and character literals, in comments, and in preprocessor directives. Following are most frequently used trigraph sequences:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Trigraph&nbsp;<\/td><td>Replacement<\/td><\/tr><tr><td>??=<\/td><td>#<\/td><\/tr><tr><td>??\/<\/td><td>\\<\/td><\/tr><tr><td>??'<\/td><td>^<\/td><\/tr><tr><td>??(<\/td><td>[<\/td><\/tr><tr><td>??)<\/td><td>]<\/td><\/tr><tr><td>??!<\/td><td>|<\/td><\/tr><tr><td>??&lt;<\/td><td>{<\/td><\/tr><tr><td>??&gt;<\/td><td>}<\/td><\/tr><tr><td>??-<\/td><td>~<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Variable Scope<\/li>\n<\/ul>\n\n\n\n<p>A scope is a region of the program and broadly speaking there are three places, where variables can be declared:<\/p>\n\n\n\n<p>\u2219 Inside a function or a block which is called local variables,&nbsp;<\/p>\n\n\n\n<p>\u2219 In the definition of function parameters which are called formal parameters.<\/p>\n\n\n\n<p>\u2219 Outside of all functions which are called global variables. We will learn what a function is, and it's parameters in subsequent chapters. Here let us explain what local and global variables are.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Local Variables&nbsp;<\/li>\n<\/ul>\n\n\n\n<p>Variables that are declared inside a function or block are local variables. They can be used only by statements that are inside that function or block of code. Local variables are not known to functions outside their own. Following is the example using local variables:<\/p>\n\n\n\n<p>#include&lt;iostream&gt;<\/p>\n\n\n\n<p>using namespace std;<\/p>\n\n\n\n<p>&nbsp;int main ()<\/p>\n\n\n\n<p>&nbsp;{<\/p>\n\n\n\n<p>&nbsp;\/\/ Local variable declaration: int a, b; int c; \/\/&nbsp;<\/p>\n\n\n\n<p>actual initialization<\/p>\n\n\n\n<p>&nbsp;a = 10;<\/p>\n\n\n\n<p>&nbsp;b = 20;<\/p>\n\n\n\n<p>&nbsp;c = a + b;<\/p>\n\n\n\n<p>&nbsp;cout &lt;&lt; c;<\/p>\n\n\n\n<p>&nbsp;return 0;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Global Variables<\/li>\n<\/ul>\n\n\n\n<p>Global variables are defined outside of all the functions, usually on top of the program. The global variables will hold their value throughout the life-time of your program. A global variable can be accessed by any function. That is, a global&nbsp;<\/p>\n\n\n\n<p>#include&lt;iostream&gt;<\/p>\n\n\n\n<p>using namespace std; \/\/ Global variable declaration: int g;<\/p>\n\n\n\n<p>&nbsp;int main ()<\/p>\n\n\n\n<p>&nbsp; {<\/p>\n\n\n\n<p>\/\/ Local variable declaration: int a, b;&nbsp;<\/p>\n\n\n\n<p>actual initialization \/\/<\/p>\n\n\n\n<p>a = 10;<\/p>\n\n\n\n<p>&nbsp; b = 20;<\/p>\n\n\n\n<p>g = a + b;<\/p>\n\n\n\n<p>&nbsp;cout &lt;&lt; g;<\/p>\n\n\n\n<p>&nbsp;return 0;<\/p>\n\n\n\n<p>&nbsp;}<\/p>\n\n\n\n<p>variable is available for use throughout your entire program after its declaration. Following is the example using global and local variables:<\/p>\n\n\n\n<p>A program can have the same name for local and global variables but the value of the local variable inside a function will take preference. For example:<\/p>\n\n\n\n<p>Include&lt;iostream&gt;<\/p>\n\n\n\n<p>Using namespace std;<\/p>\n\n\n\n<p>\/\/ Global variable declaration: \/\/<\/p>\n\n\n\n<p>int g = 20;<\/p>\n\n\n\n<p>&nbsp;int main ()&nbsp;<\/p>\n\n\n\n<p>{&nbsp;\/\/ Local variable declaration:\/\/&nbsp;<\/p>\n\n\n\n<p>int g = 10;<\/p>\n\n\n\n<p>&nbsp;cout &lt;&lt; g;&nbsp;<\/p>\n\n\n\n<p>return 0;}<\/p>\n\n\n\n<p>When the above code is compiled and executed, it produces the following result:<\/p>\n\n\n\n<p>10<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Initializing Local and Global Variables:<\/strong><\/li>\n<\/ul>\n\n\n\n<p>When a local variable is defined, it is not initialized by the system, you must initialize it yourself. Global variables are initialized automatically by the system when you define them as follows:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Data Type<\/td><td>Initializer<\/td><\/tr><tr><td>int&nbsp;<\/td><td>0<\/td><\/tr><tr><td>char<\/td><td>'\\0'&nbsp;<\/td><\/tr><tr><td>float&nbsp;<\/td><td>o<\/td><\/tr><tr><td>double&nbsp;<\/td><td>0<\/td><\/tr><tr><td>pointer<\/td><td>Null&nbsp;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>It is a good programming practice to initialize variables properly, otherwise sometimes programs would produce unexpected results.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>CONSTANTS<\/strong><\/li>\n<\/ul>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;Constants refer to fixed values that the program may not alter and they are called literals. Constants can be of any of the basic data types and can be divided into Integer Numerals, Floating-Point Numerals, Characters, Strings and Boolean Values. Again, constants are treated just like regular variables except that their values cannot be modified after their definition.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Integer Literals<\/strong><\/li>\n<\/ul>\n\n\n\n<p>&nbsp;Here are some examples of integer literals. An integer literal can be a decimal, octal, or hexadecimal constant. A prefix specifies the base or radix: 0x or 0X for hexadecimal, 0 for octal, and nothing for decimal. An integer literal can also have a suffix that is a combination of U and L, for unsigned and long, respectively. The suffix can be uppercase or lowercase and can be in any order:<\/p>\n\n\n\n<p>212 \/\/ Legal&nbsp;<\/p>\n\n\n\n<p>215u \/\/ Legal<\/p>\n\n\n\n<p>&nbsp;0xFeeL \/\/ Legal<\/p>\n\n\n\n<p>&nbsp;078 \/\/ Illegal: 8 is not an octal digit&nbsp;<\/p>\n\n\n\n<p>032UU \/\/ Illegal: cannot repeat a suffix<\/p>\n\n\n\n<p>Following are other examples of various types of Integer literals:<\/p>\n\n\n\n<p>85 \/\/ decimal&nbsp;<\/p>\n\n\n\n<p>0213 \/\/ octal<\/p>\n\n\n\n<p>&nbsp;0x4b \/\/ hexadecimal&nbsp;<\/p>\n\n\n\n<p>30 \/\/ int<\/p>\n\n\n\n<p>&nbsp;30u \/\/ unsigned int&nbsp;<\/p>\n\n\n\n<p>30l \/\/ long<\/p>\n\n\n\n<p>&nbsp;30ul \/\/ unsigned long<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Floating-point&nbsp;<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Literals A floating-point literal has an integer part, a decimal point, a fractional part, and an exponent part. You can represent floating point literals either in decimal form or exponential form. While representing using decimal form, you must include the decimal point, the exponent, or both and while representing using exponential form, you must include the integer part, the fractional part, or both. The signed exponent is introduced by e or E. Here are some examples of floating-point literals:<\/p>\n\n\n\n<p>3.14159 \/\/ Legal&nbsp;<\/p>\n\n\n\n<p>314159E-5L \/\/ Legal<\/p>\n\n\n\n<p>&nbsp; 510E \/\/ Illegal: incomplete exponent<\/p>\n\n\n\n<p>&nbsp; 210f \/\/ Illegal: no decimal or exponent&nbsp;<\/p>\n\n\n\n<p>.e55 \/\/ Illegal: missing integer or fraction.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Boolean Literals&nbsp;<\/strong><\/li>\n<\/ul>\n\n\n\n<p>There are two Boolean literals and they are part of standard C++ keywords: \u2219 A value of true representing true. \u2219 A value of false representing false. You should not consider the value of true equal to 1 and value of false equal to 0.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>&nbsp;Character Literals<\/strong><\/li>\n<\/ul>\n\n\n\n<p>&nbsp;Character literals are enclosed in single quotes. If the literal begins with L (uppercase only), it is a wide character literal (e.g., L'x') and should be stored in wchar_t type of variable. Otherwise, it is a narrow character literal (e.g., 'x') and can be stored in a simple variable of char type. A character literal can be a plain character (e.g., 'x'), an escape sequence (e.g., '\\t'), or a universal character (e.g., '\\u02C0'). There are certain characters in C++ when they are preceded by a backslash they will have special meaning and they are used to represent newlines (\\n) or tab (\\t). Here, you have a list of some of such escape sequence codes:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Escape sequence<\/td><td>Meaning<\/td><\/tr><tr><td>\\\\<\/td><td>\\ character<\/td><\/tr><tr><td>\\'&nbsp;<\/td><td>' character<\/td><\/tr><tr><td>\\?<\/td><td>? character<\/td><\/tr><tr><td>\\a<\/td><td>Alert or bell<\/td><\/tr><tr><td>\\b<\/td><td>Backspace<\/td><\/tr><tr><td>\\f<\/td><td>Form feed<\/td><\/tr><tr><td>\\n<\/td><td>newline<\/td><\/tr><tr><td>\\r<\/td><td>Carriage return<\/td><\/tr><tr><td>\\t<\/td><td>Horizontal tab<\/td><\/tr><tr><td>\\v<\/td><td>Vertical tab<\/td><\/tr><tr><td>\\ooo<\/td><td>Octal number of one to three digits<\/td><\/tr><tr><td>\\xhh<\/td><td>Hexadecimal number of one or more digits<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Following is the example to show a few escape sequences characters:<\/p>\n\n\n\n<p>&nbsp;#include&lt;iostream&gt;<\/p>\n\n\n\n<p>&nbsp;using namespace std;<\/p>\n\n\n\n<p>&nbsp;int main ()<\/p>\n\n\n\n<p>&nbsp;{&nbsp;cout &lt;&lt; \"Hello\\t World\\n\\n\";&nbsp;<\/p>\n\n\n\n<p>cout&lt;&lt; \u201cthis is my first project\u201d;&nbsp;<\/p>\n\n\n\n<p>return 0;&nbsp;}<\/p>\n\n\n\n<p>When the above code is compiled and executed, it produces the following result:<\/p>\n\n\n\n<p>Hello World<\/p>\n\n\n\n<p>this is my first project<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>String Literals&nbsp;<\/li>\n<\/ul>\n\n\n\n<p>String literals are enclosed in double quotes. A string contains characters that are similar to character literals: plain characters, escape sequences, and universal characters. You can break a long line into multiple lines using string literals and separate them using whitespaces. Here are some examples of string literals. All the three forms are identical strings.&nbsp;<\/p>\n\n\n\n<p>hello, dear\"&nbsp;<\/p>\n\n\n\n<p>\"hello, \\ dear\"&nbsp;<\/p>\n\n\n\n<p>\"hello, \"&nbsp;<\/p>\n\n\n\n<p>\"d\"<\/p>\n\n\n\n<p>&nbsp;\"ear\"<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Defining Constants<\/li>\n<\/ul>\n\n\n\n<p>&nbsp;There are two simple ways in C++ to define constants:&nbsp;<\/p>\n\n\n\n<p>\u2219 Using #define a preprocessor.&nbsp;<\/p>\n\n\n\n<p>\u2219 Using const keyword.<\/p>\n\n\n\n<p>The #define Preprocessor Following is the form to use #define preprocessor to define a constant:<\/p>\n\n\n\n<p>#define identifier value<\/p>\n\n\n\n<p>Following example explains it in detail:<\/p>\n\n\n\n<p>#include&lt;iostream&gt;&nbsp;<\/p>\n\n\n\n<p>using namespace std;<\/p>\n\n\n\n<p>#define LENGTH 10<\/p>\n\n\n\n<p>&nbsp;#define WIDTH 5<\/p>\n\n\n\n<p>&nbsp;#define NEWLINE '\\n'<\/p>\n\n\n\n<p>&nbsp;int main()<\/p>\n\n\n\n<p>&nbsp;{<\/p>\n\n\n\n<p>&nbsp;int area;<\/p>\n\n\n\n<p>&nbsp;area = LENGTH * WIDTH;<\/p>\n\n\n\n<p>&nbsp;cout &lt;&lt; area;&nbsp;<\/p>\n\n\n\n<p>cout &lt;&lt; NEWLINE;&nbsp;<\/p>\n\n\n\n<p>return 0;<\/p>\n\n\n\n<p>&nbsp;}<\/p>\n\n\n\n<p>When the above code is compiled and executed, it produces the following result:<\/p>\n\n\n\n<p>50<\/p>\n\n\n\n<p>The const Keyword You can use const prefix to declare constants with a specific type as follows:<\/p>\n\n\n\n<p>const type variable = value;<\/p>\n\n\n\n<p>Following example explains it in detail:&nbsp;<\/p>\n\n\n\n<p>#include&lt;iostream&gt;<\/p>\n\n\n\n<p>&nbsp;using namespace std;<\/p>\n\n\n\n<p>&nbsp;int main()&nbsp;<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>&nbsp;const int LENGTH = 10;<\/p>\n\n\n\n<p>&nbsp;const int WIDTH = 5;<\/p>\n\n\n\n<p>&nbsp;const char NEWLINE = '\\n';&nbsp;<\/p>\n\n\n\n<p>int area;<\/p>\n\n\n\n<p>area = LENGTH * WIDTH;<\/p>\n\n\n\n<p>&nbsp;cout &lt;&lt; area;&nbsp;<\/p>\n\n\n\n<p>cout &lt;&lt; NEWLINE;<\/p>\n\n\n\n<p>&nbsp;return 0;&nbsp;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>&nbsp;When the above code is compiled and executed, it produces the following result:<\/p>\n\n\n\n<p>&nbsp;50<\/p>\n\n\n\n<p>&nbsp;Note that it is a good programming practice to define constants in CAPITALS.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>ARRAYS:<\/li>\n<\/ul>\n\n\n\n<p>An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier.<\/p>\n\n\n\n<p>&nbsp;That means that, for example, we can store 5 values of type int in an array without having to declare 5 different variables, each one with a different identifier. Instead of that, using an array we can store 5 different values of the same type, int for example, with a unique identifier. For example, an array to contain 10 integer values of type int called billy could be represented like this:<\/p>\n\n\n\n<p>1 &nbsp; &nbsp; 2 3 4 5 &nbsp; &nbsp; 6 &nbsp; &nbsp; 7 &nbsp; &nbsp; &nbsp; 8 &nbsp; &nbsp; &nbsp; &nbsp; 9&nbsp; &nbsp; &nbsp; &nbsp; 10<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><\/td><td><\/td><td><\/td><td><\/td><td><\/td><td><\/td><td><\/td><td><\/td><td><\/td><td><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>MULTI-DIMENSIONAL ARRAYS:<\/li>\n<\/ul>\n\n\n\n<p>Multi-dimensional arrays are derived from the basic or built in data types<\/p>\n\n\n\n<p>Of C language.<\/p>\n\n\n\n<p>Two dimensional arrays are understood as rows and columns with applications including two dimensional matrices.<\/p>\n\n\n\n<p>Mostly two-dimensional arrays are used in multi-dimensional array.<\/p>\n\n\n\n<p>This is the three-dimensional array.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>TWO-DIMENSIONAL ARRAY:<\/li>\n<\/ul>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int b[2][3]={(b1, b2, b3)(b4, b5, b6)};<\/p>\n\n\n\n<p>in this example -\u201cint b\u201d is name of array&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u201c[2]\u201dis indicating the number of rows&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; \u201c[3]\u201dis indicating the number of columns<\/p>\n\n\n\n<p>&nbsp; &nbsp; (b1, b2, b3) are the elements in the first row<\/p>\n\n\n\n<p>&nbsp; &nbsp; (b4, b5, b6) are the elements in second row&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Declaration of array: -<\/li>\n<\/ul>\n\n\n\n<p>How to declare a multidimensional array?<\/p>\n\n\n\n<p>Int b[2][3]<\/p>\n\n\n\n<p>The name of the array is b<\/p>\n\n\n\n<p>The type of elements is int<\/p>\n\n\n\n<p>The size of element is 2*3=6<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Initialization: -<\/li>\n<\/ul>\n\n\n\n<p>Use braces to separate rows in 2-d array: -<\/p>\n\n\n\n<p>int c [4][3] = {(1,2,3), (4,5,6), (7,8,9), (10,11,12)};<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Input for two dimensional arrays: -<\/li>\n<\/ul>\n\n\n\n<p>Data may be input into two-dimensional arrays using nested for loops interactively or with data type.<\/p>\n\n\n\n<p>A nested loop is used to input elements in a two-dimensional array.<\/p>\n\n\n\n<p>In this way by increasing the index value of the array the elements can be entered in a two-dimensional array.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Output for two-dimensional array: -<\/li>\n<\/ul>\n\n\n\n<p>The output of a 2-dimensional array should be informed of rows and columns for readability.<\/p>\n\n\n\n<p>Nested for loops are used to print the rows and column order.<\/p>\n\n\n\n<p>By increasing the index value of the array the elements stored at that index value are printed on the output screen.<\/p>\n\n\n\n<p>Code for array: -<\/p>\n\n\n\n<p>#include&lt;iostream&gt;<\/p>\n\n\n\n<p>Using namespace std;<\/p>\n\n\n\n<p>Void main ()<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>int a [3] [4];<\/p>\n\n\n\n<p>int i, j;<\/p>\n\n\n\n<p>clrscr ();<\/p>\n\n\n\n<p>print f (\u201center the element in the array:\u201d);<\/p>\n\n\n\n<p>for (i=0; i&lt;3; i++)<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>for(j=0; j&lt;3: j++)<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>scanf(\u201c%d\u201d, &amp; a[i] [j]);<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>for(i=0;i&lt;3:i++)<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>for(j=0;j&lt;3;j++)<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>printf(\u201c%d\u201d,a[i][j]);<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>print(\u201c\\n\u201d);<\/p>\n\n\n\n<p>getch();<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>This code give you output:<\/p>\n\n\n\n<p>1<\/p>\n\n\n\n<p>2<\/p>\n\n\n\n<p>3<\/p>\n\n\n\n<p>4<\/p>\n\n\n\n<p>5<\/p>\n\n\n\n<p>6<\/p>\n\n\n\n<p>7<\/p>\n\n\n\n<p>8<\/p>\n\n\n\n<p>9<\/p>\n\n\n\n<p>1 2 3<\/p>\n\n\n\n<p>4 5 6<\/p>\n\n\n\n<ol start=\"7\" class=\"wp-block-list\">\n<li>8 9<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Storage Allocation: -<\/li>\n<\/ul>\n\n\n\n<p>In storage allocation of array contiguous memory is allocated in all the array elements.<\/p>\n\n\n\n<p>The storage arrangement shows in the example uses the array subscript it is also called the array indices.<\/p>\n\n\n\n<p>Array declaration: int a [3] [4];<\/p>\n\n\n\n<p>Array elements:<\/p>\n\n\n\n<p>a [0] [0] a [0] [1] a [0] [2] a [0] [3]<\/p>\n\n\n\n<p>a [1] [0] a [1] [1] a [1] [2] a [1] [3]<\/p>\n\n\n\n<p>a [2] [0] a [2] [1] a [2] [2] a [2] [3]<\/p>\n\n\n\n<p>Storage Allocation:<\/p>\n\n\n\n<p>a [0] [0]<\/p>\n\n\n\n<p>a [0] [1]<\/p>\n\n\n\n<p>row0: a [0] [2]<\/p>\n\n\n\n<p>a [0] [3]<\/p>\n\n\n\n<p>a [1] [0]<\/p>\n\n\n\n<p>row1: a [1] [1]<\/p>\n\n\n\n<p>a [1] [2]<\/p>\n\n\n\n<p>a [1] [3]<\/p>\n\n\n\n<p>a [2] [0]<\/p>\n\n\n\n<p>row2: a [2] [1]<\/p>\n\n\n\n<p>a [2] [2]<\/p>\n\n\n\n<p>a [2] [3]<\/p>\n\n\n\n<p>code for array: -<\/p>\n\n\n\n<p>#include&lt;iostream&gt;<\/p>\n\n\n\n<p>using namespace std;<\/p>\n\n\n\n<p>void main ()<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>int a [3] [3], b [3] [3], c[3] [3];<\/p>\n\n\n\n<p>int I, j;<\/p>\n\n\n\n<p>clrscr ();<\/p>\n\n\n\n<p>print f (\u201center the element in both the array:\u201d);<\/p>\n\n\n\n<p>for (i=0; i&lt;3; i++)<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>for (j=0; j&lt;3; j++);<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>scan f (\u201c%d\u201d, &amp; a [i] [j]);<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>for (i=0; i&lt;3; i++)<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>for (j=0; j&lt;3; j++)<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>c=a [i] [j] +b [i] [j];<\/p>\n\n\n\n<p>print f(\u201c%d\u201d, c [i] [j]);<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>print(\u201c\\n\u201d)<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>getch;<\/p>\n\n\n\n<p>this code will give you output as-<\/p>\n\n\n\n<p>1<\/p>\n\n\n\n<p>2<\/p>\n\n\n\n<p>3<\/p>\n\n\n\n<p>4<\/p>\n\n\n\n<p>5<\/p>\n\n\n\n<p>6<\/p>\n\n\n\n<p>7<\/p>\n\n\n\n<p>8<\/p>\n\n\n\n<p>9<\/p>\n\n\n\n<p>1<\/p>\n\n\n\n<p>2<\/p>\n\n\n\n<p>3<\/p>\n\n\n\n<p>4<\/p>\n\n\n\n<p>5<\/p>\n\n\n\n<p>6<\/p>\n\n\n\n<p>7<\/p>\n\n\n\n<p>8<\/p>\n\n\n\n<p>9<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp; 4 6&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8 10 12<\/p>\n\n\n\n<p>14 16 18&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>String in array: -<\/li>\n<\/ul>\n\n\n\n<p>The group of characters are known as strings when the array is implemented. It is known as string in array.<\/p>\n\n\n\n<p>For example-<\/p>\n\n\n\n<p>Char name [5] =<\/p>\n\n\n\n<p>\u201csunny\u201d<\/p>\n\n\n\n<p>It is compulsory to include header file &lt;string.h&gt; The following functionality can be implemented they are as follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>strlen ()<\/li>\n\n\n\n<li>strcpy ()<\/li>\n\n\n\n<li>strcmp ()<\/li>\n\n\n\n<li>strmpi ()<\/li>\n\n\n\n<li>strcat ()<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>strlen ()<\/li>\n<\/ul>\n\n\n\n<p>stands for string length This function is used when we need to find the length of string.<\/p>\n\n\n\n<p>For example, we have a char string name [10] in brackets. Size 10 and we are trying to store \u201csunny\u201d.<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; String name[10]= \u201csunny\u201d.<\/p>\n\n\n\n<p>Size of the array is 10 means we can store maximum 10 bytes of data but output of the above statement would be above statement5.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Strcmp ()<\/li>\n<\/ul>\n\n\n\n<p>The function is used to compare to string. Strcmp() uses ASCII standard to compare two strings.<\/p>\n\n\n\n<p>Char n[10] = \u201cPoonam\u201d<\/p>\n\n\n\n<p>Char n[10]= \u201csunny\u201d<\/p>\n\n\n\n<p>Strcmp (destination string, source string)<\/p>\n\n\n\n<p>Strcmp (n, m)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Strcmp i( )<\/li>\n<\/ul>\n\n\n\n<p>This function is also used for comparing two strings.<\/p>\n\n\n\n<p>But the difference is for this function both \u201cpoonam\u201d and poOnaM are the same.<\/p>\n\n\n\n<p>This will return() when compared.<\/p>\n\n\n\n<p>But in case of strcmpi() it will be the value<\/p>\n\n\n\n<p>Strcmpi (destination string, source string)<\/p>\n\n\n\n<p>Strcmpi (n, m);<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Strcpy ()<\/li>\n<\/ul>\n\n\n\n<p>This function is used to copy one string to another string.<\/p>\n\n\n\n<p>For example, we have two character arrays.<\/p>\n\n\n\n<p>m [10]= \u201csunny\u201d, n [10];<\/p>\n\n\n\n<p>Strcpy()also has two parameters.<\/p>\n\n\n\n<p>Strcpy (destination string, source string)<\/p>\n\n\n\n<p>We will write: strcpy (n, m);<\/p>\n\n\n\n<p>We will get: m [10]: \u201csunny\u201d, n [10]= \u201csunny\u201d<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Strcat()\/appends<\/li>\n<\/ul>\n\n\n\n<p>This function is use to concatenate two strings strcat has two parameters&nbsp;<\/p>\n\n\n\n<p>Syntax:<\/p>\n\n\n\n<p>Strcat (destination string, source string)<\/p>\n\n\n\n<p>Char n[5]= \u201chello\u201d<\/p>\n\n\n\n<p>Cher n [5]=\u201dworld\u201d<\/p>\n\n\n\n<p>Strcat (n, m)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Strpy()<\/li>\n<\/ul>\n\n\n\n<p>The function used to copy are string to another string<\/p>\n\n\n\n<p>For example, are have two character<\/p>\n\n\n\n<p>m [10]= \u201csunny\u201d, n [10];<\/p>\n\n\n\n<p>Strcpy(destination string, source code)<\/p>\n\n\n\n<p>We can also write as= strcpy(n\/m)<\/p>\n\n\n\n<p>We will get =m [10]= \u201csunny\u201d, n [10]= \u201csunny\u201d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>History of C++ C++ evolved from C, which earlier from two previous programming languages, BCPL and B language. BCPL was developed in 1967 by Martin Richard as a language for writing operating system software and compilers. B language was developed by Ken Thompson. C language evolved from B language, else a programming language designed by [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":26711,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[],"content_type":[36252],"class_list":["post-26708","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","content_type-tutorials"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>C++ Tutorial for Beginners - Learn All about C++ Programming<\/title>\n<meta name=\"description\" content=\"C++ evolved from C, which earlier from two previous programming languages, BCPL and B language.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C++ Tutorial for Beginners\" \/>\n<meta property=\"og:description\" content=\"C++ evolved from C, which earlier from two previous programming languages, BCPL and B language.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-24T09:13:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-10-21T05:59:32+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/shutterstock_1081142213.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"542\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Great Learning Editorial Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/Great_Learning\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Great Learning Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"21 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/cpp-tutorial\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/cpp-tutorial\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"C++ Tutorial for Beginners\",\"datePublished\":\"2021-03-24T09:13:30+00:00\",\"dateModified\":\"2022-10-21T05:59:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/cpp-tutorial\\\/\"},\"wordCount\":5006,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/cpp-tutorial\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/shutterstock_1081142213.jpg\",\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/cpp-tutorial\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/cpp-tutorial\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/cpp-tutorial\\\/\",\"name\":\"C++ Tutorial for Beginners - Learn All about C++ Programming\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/cpp-tutorial\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/cpp-tutorial\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/shutterstock_1081142213.jpg\",\"datePublished\":\"2021-03-24T09:13:30+00:00\",\"dateModified\":\"2022-10-21T05:59:32+00:00\",\"description\":\"C++ evolved from C, which earlier from two previous programming languages, BCPL and B language.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/cpp-tutorial\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/cpp-tutorial\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/cpp-tutorial\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/shutterstock_1081142213.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/shutterstock_1081142213.jpg\",\"width\":1000,\"height\":542,\"caption\":\"C++ tutorial\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/cpp-tutorial\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"IT\\\/Software Development\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/software\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"C++ Tutorial for Beginners\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"C++ Tutorial for Beginners - Learn All about C++ Programming","description":"C++ evolved from C, which earlier from two previous programming languages, BCPL and B language.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"C++ Tutorial for Beginners","og_description":"C++ evolved from C, which earlier from two previous programming languages, BCPL and B language.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","article_published_time":"2021-03-24T09:13:30+00:00","article_modified_time":"2022-10-21T05:59:32+00:00","og_image":[{"width":1000,"height":542,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/shutterstock_1081142213.jpg","type":"image\/jpeg"}],"author":"Great Learning Editorial Team","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/Great_Learning","twitter_site":"@Great_Learning","twitter_misc":{"Written by":"Great Learning Editorial Team","Est. reading time":"21 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"C++ Tutorial for Beginners","datePublished":"2021-03-24T09:13:30+00:00","dateModified":"2022-10-21T05:59:32+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/"},"wordCount":5006,"commentCount":0,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/shutterstock_1081142213.jpg","articleSection":["IT\/Software Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/","url":"https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/","name":"C++ Tutorial for Beginners - Learn All about C++ Programming","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/shutterstock_1081142213.jpg","datePublished":"2021-03-24T09:13:30+00:00","dateModified":"2022-10-21T05:59:32+00:00","description":"C++ evolved from C, which earlier from two previous programming languages, BCPL and B language.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/shutterstock_1081142213.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/shutterstock_1081142213.jpg","width":1000,"height":542,"caption":"C++ tutorial"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/cpp-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"IT\/Software Development","item":"https:\/\/www.mygreatlearning.com\/blog\/software\/"},{"@type":"ListItem","position":3,"name":"C++ Tutorial for Beginners"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/shutterstock_1081142213.jpg",1000,542,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/shutterstock_1081142213-150x150.jpg",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/shutterstock_1081142213-300x163.jpg",300,163,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/shutterstock_1081142213-768x416.jpg",768,416,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/shutterstock_1081142213.jpg",1000,542,false],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/shutterstock_1081142213.jpg",1000,542,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/shutterstock_1081142213.jpg",1000,542,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/shutterstock_1081142213.jpg",640,347,false],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/shutterstock_1081142213.jpg",96,52,false],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/03\/shutterstock_1081142213.jpg",150,81,false]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"History of C++ C++ evolved from C, which earlier from two previous programming languages, BCPL and B language. BCPL was developed in 1967 by Martin Richard as a language for writing operating system software and compilers. B language was developed by Ken Thompson. C language evolved from B language, else a programming language designed by&hellip;","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/26708","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=26708"}],"version-history":[{"count":15,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/26708\/revisions"}],"predecessor-version":[{"id":111514,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/26708\/revisions\/111514"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/26711"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=26708"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=26708"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=26708"},{"taxonomy":"content_type","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/content_type?post=26708"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}