<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lubna Fathima</title>
    <description>The latest articles on DEV Community by Lubna Fathima (@lubnafathima).</description>
    <link>https://dev.to/lubnafathima</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F897423%2Fe04756cd-88b4-4365-a2d1-a6fd4c6b2752.jpg</url>
      <title>DEV Community: Lubna Fathima</title>
      <link>https://dev.to/lubnafathima</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lubnafathima"/>
    <language>en</language>
    <item>
      <title>Variables and Data Types in C++ : Part 2</title>
      <dc:creator>Lubna Fathima</dc:creator>
      <pubDate>Fri, 20 Jan 2023 05:18:57 +0000</pubDate>
      <link>https://dev.to/lubnafathima/variables-and-data-types-in-c-part-2-2269</link>
      <guid>https://dev.to/lubnafathima/variables-and-data-types-in-c-part-2-2269</guid>
      <description>&lt;h2&gt;
  
  
  Introduction to Variables
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A variable is a storage place that has some memory allocated to it. It is used to store some form of data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Different types of variables require different amounts of memory.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Variable Declaration&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In C++, we can declare variables as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;data_type: Type of the data that can be stored in this variable. It can be int, float, double, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;variable_name: Name given to the variable.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;data_type&lt;/span&gt; &lt;span class="n"&gt;variable_name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 

&lt;span class="n"&gt;Example&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this way, we can only create a variable in the memory location. Currently, it doesn’t have any value. We can assign the value in this variable by using two ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;By using variable initialization.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;By taking input&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here, we can discuss only the first way, i.e., variable initialization. We will discuss the second way later.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;data_type&lt;/span&gt; &lt;span class="n"&gt;variable_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 

&lt;span class="n"&gt;Example&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rules for defining variables in C++&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You can’t begin with a number. Ex- 9a can't be a variable, but a9 can be a variable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Spaces and special characters except for underscore(_) are not allowed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;C++ keywords (reserved words) must not be used as a variable name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;C++ is case-sensitive, meaning a variable with the name ‘A’ is different from a variable with the name ‘a. (Difference in the upper-case and lower-case holds true).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;C++ Keywords&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1673759283293%2F9f19b65a-f06d-4376-900c-e92938bf5f92.png%2520align%3D" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1673759283293%2F9f19b65a-f06d-4376-900c-e92938bf5f92.png%2520align%3D" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction to Data Types
&lt;/h2&gt;

&lt;p&gt;All variables use data type during declaration to restrict the type of data to be stored.&lt;/p&gt;

&lt;p&gt;Therefore, we can say that data types tell the variables the type of data they can store.&lt;/p&gt;

&lt;p&gt;Pre-defined data types available in C++ are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;int: Integer value&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;unsigned int: Can store only positive integers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;float, double: Decimal number&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;char: Character values (including special characters)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;unsigned char: Character values&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;bool: Boolean values (true or false)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;long: Contains integer values but with the larger size&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;unsigned long: Contains large positive integers or 0&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;short: Contains integer values but with smaller size&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Table for datatype and its size in C++:
&lt;/h3&gt;

&lt;p&gt;(This can vary from compiler to compiler and system to system depending on the version you are using)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1673759737356%2Ff0e58669-ddc0-48ae-8ebd-cdcdd39e7463.png%2520align%3D" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1673759737356%2Ff0e58669-ddc0-48ae-8ebd-cdcdd39e7463.png%2520align%3D" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="c1"&gt;// Integer (whole number)&lt;/span&gt;

&lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="n"&gt;interestRate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;5.99&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Floating point number&lt;/span&gt;

&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;myLetter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sc"&gt;'D'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Character&lt;/span&gt;

&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;isPossible&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Boolean &lt;/span&gt;

&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;myText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Coding Ninjas"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// String&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  auto keyword in c++
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The auto keyword specifies that the type of the declared variable will automatically be deduced from its initializer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It would set the variable type to initialize that variable’s value type or set the function return type as the value to be returned.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt; &lt;span class="c1"&gt;// will set the variable as int type&lt;/span&gt;

&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;7.65&lt;/span&gt; &lt;span class="c1"&gt;//will set the variable b as a float &lt;/span&gt;

&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"abcdefg"&lt;/span&gt; &lt;span class="c1"&gt;// will set the variable c as string&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Scope of Variables
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The scope of a variable refers to the region of visibility or availability of a variable i.e the parts of your program in which the variable can be used or accessed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There are mainly two types of variable scopes: &lt;strong&gt;Local Scope and Global Scope&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Local Scope&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Variables declared within the body of a function or block are said to have local scope and are referred to as local variables.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;They can be used only by the statements inside the body of the function or the block they are declared within. Example:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;person&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;gender&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Male"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="c1"&gt;//This variable gender is Local to the function person () &lt;/span&gt;
&lt;span class="c1"&gt;//and cannot be used outside this function.&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Global Scope&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The variables whose scope is not limited to any block or function are said to have global scope and are referred to as 'global variables.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Global variables are declared outside of all the functions, generally on the top of the program, and can be accessed from any part of your program.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;These variables hold their values throughout the lifetime of the program. Example:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class="c1"&gt; &lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="c1"&gt;// Global variable declaration: and can be used anywhere in code &lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Using global variable &lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Types of Variables, Overflow and Underflow
&lt;/h2&gt;

&lt;p&gt;There are three types of variables based on the scope of the variable in C++ -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Local Variables&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Instance Variables&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Static Variables&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Local Variables
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The variables declared within the body of a function or block are known as local variables and are created(occupy memory) when the program enters the block or makes a function call.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The local variables get destroyed(memory is released) after exiting from the block or returning from the function call.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;They can be used only by the statements inside the body of the function or the block they are declared within. Example:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
&lt;span class="c1"&gt;//Local variable marks &lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"Student obtained "&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;marks&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"marks. "&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;Output&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Student&lt;/span&gt; &lt;span class="n"&gt;obtained&lt;/span&gt; &lt;span class="mi"&gt;92&lt;/span&gt; &lt;span class="n"&gt;marks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Instance variables
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Instance variables are non-static variables that belong to an instance of a class and are declared in a class outside any method, constructor, or block.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;These variables are created when an object of the class is created and destroyed when the object is destroyed and are accessible to all the constructors, methods, or blocks in the class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Each object of the class within which the instance variable is declared will have its separate copy or instance of this variable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Unlike local variables, we may use access specifiers for instance variables. Example:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;A&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// by default private instance variables &lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="nl"&gt;public:&lt;/span&gt;
        &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// public instance variable &lt;/span&gt;
    &lt;span class="n"&gt;Void&lt;/span&gt; &lt;span class="n"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
        &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
        &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Static Variables
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Static variables are declared using the keyword 'static, within a class outside any method, constructor, or block.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Space is allocated only once for static variables i.e we have a single copy of the static variable corresponding to a class, unlike instance variables.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The static variables are created at the start of the program and get destroyed at the end of the program ie the lifetime of a static variable is the lifetime of the program.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Static variables are initialized only once and they hold their value throughout the lifetime of the program. Example:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;A&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;//static variable &lt;/span&gt;
    &lt;span class="n"&gt;Void&lt;/span&gt; &lt;span class="n"&gt;func&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
        &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Overflow and Underflow
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Overflow occurs when we assign a value to more than its range, and Underflow is the opposite of overflow.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the case of overflow and underflow, the C++ compiler doesn't throw any errors.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It simply changes the value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For example, in the case of an int variable, the maximum value of the int data type is 2,147,483,647 (NT MAX) and after incrementing 1 on this value, it will return -2,147,483,648 (INTMIN). This is known as overflow.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The minimum value of the int data type is -2,147,483,648 (INT MIN) and after decrementing 1 on this value, it will return 2,147,483,647 (INT MAX). This is known as underflow. Example:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class="c1"&gt; &lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;INT_MAX&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;//2147483647 &lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;INT_MIN&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;//-2147483648 &lt;/span&gt;
    &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;Output&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; 
&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2147483648&lt;/span&gt; 
&lt;span class="mi"&gt;2147483647&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Typecasting
&lt;/h2&gt;

&lt;p&gt;Converting an expression of a given data type into another data type is known as type-casting or type-conversion.&lt;/p&gt;

&lt;p&gt;There are two types of type conversions:&lt;br&gt;&lt;br&gt;
- Implicit Type Conversion&lt;br&gt;&lt;br&gt;
- Explicit Type Conversion&lt;/p&gt;
&lt;h3&gt;
  
  
  Implicit Type Conversion
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It is automatically performed by the compiler itself to ensure that the calculations between the same data types take place and avoid any loss of data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Such types of conversions take place when more than one data type is present in an expression.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The rule associated with implicit type conversions involves upgrading the data type of all the variables to the data type of the variable with the "largest data type".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The order of automatic type conversion or the sequence for smallest to largest data type(left to right) for this type conversion is given as:&lt;br&gt;&lt;br&gt;
&lt;strong&gt;bool-&amp;gt; char -&amp;gt; short int -&amp;gt; int -&amp;gt; unsigned int -&amp;gt; long -&amp;gt; unsigned-&amp;gt; long long -&amp;gt; float-&amp;gt; double -&amp;gt; long double&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class="c1"&gt; &lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
    &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;letter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sc"&gt;'c'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="n"&gt;dec&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;res1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// here Letter is implicitly converted to int and its va // ASCII value of c i.e. 99 &lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;res1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="n"&gt;res2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;res1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;dec&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// here resi is implicitly converted to float. &lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;res2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;Output&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;299&lt;/span&gt; &lt;span class="mf"&gt;299.7&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Explicit Type Conversion:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This process is also called typecasting, and it is user-defined.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Here the user can typecast the result to make it of a particular data type which may lead to data loss and is also known as forceful casting.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Syntax:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;expression&lt;/span&gt; 
&lt;span class="n"&gt;Example&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; 
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;dbl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;5.6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;dbl&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Here dbl is explicity con verted to int i.e value of dbl becomes 5. &lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;"Result = "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>welcome</category>
      <category>community</category>
      <category>csharp</category>
      <category>gamedev</category>
    </item>
    <item>
      <title>Introduction to C++ : Part 1</title>
      <dc:creator>Lubna Fathima</dc:creator>
      <pubDate>Sat, 14 Jan 2023 12:39:55 +0000</pubDate>
      <link>https://dev.to/lubnafathima/introduction-to-c-part-1-70d</link>
      <guid>https://dev.to/lubnafathima/introduction-to-c-part-1-70d</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction, Features and Uses of C++&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;C++ is a general-purpose programming language and is widely used nowadays for &lt;strong&gt;competitive programming&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It has &lt;strong&gt;imperative, object-oriented, and generic programming&lt;/strong&gt; features.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;C++ runs on lots of platforms like &lt;strong&gt;Windows, Linux, Unix, Mac, etc.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It can be used to develop &lt;strong&gt;operating systems, browsers, games&lt;/strong&gt;, and so on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This makes C++ powerful as well as flexible.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can run programs and practice them on your local desktop, Using one of these compilers: &lt;strong&gt;Code blocks, VS Code, Dev C++, Atom&lt;/strong&gt;, and many more.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Features of C++
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Simple&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Portability&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Powerful and Fast&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Rich Library&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Platform Dependent&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mid-level programming language&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Structured programming language&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Object-Oriented&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Case Sensitive&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Compiler Based&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Syntax based language&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pointers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Dynamic Memory Management&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Simple&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;C++ is a simple language because it provides a &lt;strong&gt;structured approach&lt;/strong&gt; (to break the problem into parts), a &lt;strong&gt;rich set of library functions, data types,&lt;/strong&gt; etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It allows us to follow both &lt;strong&gt;procedural&lt;/strong&gt; as well as &lt;strong&gt;functional approaches&lt;/strong&gt; to design our flow of control.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Portability:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It is the concept of &lt;strong&gt;carrying the instruction&lt;/strong&gt; from one system to another system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In C++ language &lt;strong&gt;.cpp file&lt;/strong&gt; contains &lt;strong&gt;source code&lt;/strong&gt;, and we can also edit this code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;.exe file&lt;/strong&gt; contains the &lt;strong&gt;application&lt;/strong&gt;, which is the only file that can be executed. W&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When we write and compile any C++ program on the Windows operating system, it &lt;strong&gt;efficiently runs&lt;/strong&gt; on other window-based systems.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Powerful:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;C++ is a very powerful programming language, and it has a &lt;strong&gt;wide variety&lt;/strong&gt; of data types, functions, control statements, decision-making statements, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;C++ is a &lt;strong&gt;fast language&lt;/strong&gt; as compilation and execution time is less.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Also, it has a wide variety of &lt;strong&gt;data types, functions &amp;amp; operators&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Rich Library&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;C++ library is full of &lt;strong&gt;in-built functions&lt;/strong&gt; that save a tremendous amount of time in the software development process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;As it contains almost &lt;strong&gt;all kinds of functionality&lt;/strong&gt;, a programmer can need it in the development process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hence, saving &lt;strong&gt;time&lt;/strong&gt; and increasing development &lt;strong&gt;speed&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Platform Dependent:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Platform-dependent language means the language in which programs can be &lt;strong&gt;executed only on the operating system where it is developed &amp;amp; compiled&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It &lt;strong&gt;cannot run or execute&lt;/strong&gt; on any other operating system. E.g., compiled programs on Linux won’t run on Windows.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Mid-level programming language:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;C++ can do both &lt;strong&gt;low-level &amp;amp; high-level&lt;/strong&gt; programming.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;That is the reason why C++ is known as a mid-level programming language.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Structured programming language&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;C++ is a structured programming language as it allows to &lt;strong&gt;break off&lt;/strong&gt; of the program into parts &lt;strong&gt;using functions&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;So, it is &lt;strong&gt;easy to understand and modify&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Object-oriented&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;C++ is an &lt;strong&gt;object-oriented programming&lt;/strong&gt; language.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;OOPs make &lt;strong&gt;development and maintenance easier&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;whereas, in Procedure-oriented programming language, it is &lt;strong&gt;not easy&lt;/strong&gt; to manage if code grows as project size grows.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It follows the concept of oops like &lt;strong&gt;polymorphism, inheritance, encapsulation, abstraction.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Case sensitive&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;C++ is a &lt;strong&gt;case-sensitive&lt;/strong&gt; programming language.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In C++ programming, '&lt;strong&gt;break and BREAK'&lt;/strong&gt; both are different.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Compiler-Based:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;C++ is a &lt;strong&gt;compiler-based&lt;/strong&gt; language, unlike Python.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;C++ programs used to be compiled, and their &lt;strong&gt;executable file is used to run&lt;/strong&gt; it due to which C++ is a relatively faster language than Java and Python.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Syntax-based language&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;C++ is a &lt;strong&gt;strongly typed syntax-based&lt;/strong&gt; programming language.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If any language &lt;strong&gt;follows the rules and regulations strictly&lt;/strong&gt;, it is known as a strongly syntax-based language.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Other examples of syntax-based languages are C, C++, Java, .net etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pointer&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;C++ supports pointers that allow the user to &lt;strong&gt;deal directly with the memory&lt;/strong&gt; and &lt;strong&gt;control&lt;/strong&gt; the programmer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This makes it very suitable for &lt;strong&gt;low-level tasks&lt;/strong&gt; and &lt;strong&gt;very complicated projects.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is known to &lt;strong&gt;increase the speed of execution&lt;/strong&gt; by decreasing the memory access overhead.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Dynamic Memory Management&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It &lt;strong&gt;supports&lt;/strong&gt; the feature of dynamic memory allocation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In C++ language, we can &lt;strong&gt;free the allocated memory&lt;/strong&gt; by calling the &lt;strong&gt;free()&lt;/strong&gt; function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;These features are missing in languages like C.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Uses of C++
&lt;/h3&gt;

&lt;p&gt;There are several benefits of using C++ because of its &lt;strong&gt;features and security&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;below are some uses of C++ Programming Language&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Operating Systems&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;One of the key requirements of an Operating System is that it should be &lt;strong&gt;very fast&lt;/strong&gt; as it is responsible for &lt;strong&gt;scheduling and running&lt;/strong&gt; the user programs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;strongly typed and fast nature&lt;/strong&gt; of C++ makes it an ideal candidate for writing operating systems.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Also, C++ has a &lt;strong&gt;vast collection of system-level functions&lt;/strong&gt; that also help in writing low-level programs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Microsoft Windows or Mac OS X, or Linux all operating systems have some parts programmed in C++.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Games&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Again since most, games need to be &lt;strong&gt;faster to support smooth gameplay&lt;/strong&gt;, C++ is extensively used in game design.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;C++ can easily &lt;strong&gt;manipulate hardware resources&lt;/strong&gt;, and it can also provide procedural programming for CPU-intensive functions.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Browsers&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;With the &lt;strong&gt;fast performance&lt;/strong&gt; of C++, most browsers have their &lt;strong&gt;rendering&lt;/strong&gt; software written in C++.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Browsers are mostly used in C++ for &lt;strong&gt;rendering purposes&lt;/strong&gt;. Rendering engines need to be faster in execution as most people do not like to wait for the web page to be loaded.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Libraries&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Many &lt;strong&gt;high-level libraries&lt;/strong&gt; use C++ as the core programming language.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For example, &lt;strong&gt;TensorFlow&lt;/strong&gt; uses C++ as the back-end programming language.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Such libraries required &lt;strong&gt;high-performance computations&lt;/strong&gt; because they involve multiplications of huge matrices to train Machine Learning models.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;As a result, performance becomes critical.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;C++ comes to the rescue in such libraries.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Graphics&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;C++ is widely used in almost all &lt;strong&gt;graphics applications&lt;/strong&gt; that require &lt;strong&gt;fast rendering, image processing, real-time physics, and mobile sensors&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cloud/Distributed Systems:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Cloud storage systems use &lt;strong&gt;scalable file systems&lt;/strong&gt; that work close to the hardware.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Also, the multi-threading libraries in C++ provide h*&lt;em&gt;igh concurrency and load tolerance.&lt;/em&gt;*&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Embedded Systems:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;C++ is &lt;strong&gt;closer to the hardware leve&lt;/strong&gt;l, and so it is quite useful in &lt;strong&gt;embedded systems&lt;/strong&gt; as the software and hardware in these are closely coupled.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Many embedded systems use C++, Such as &lt;strong&gt;smartwatches, MP3 players, GPS systems&lt;/strong&gt;, etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Compilers&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compilers of various programming languages use &lt;strong&gt;C++ as the back-end&lt;/strong&gt; programming language.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How to implement a code in C++&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Headers in C++
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;C++ code begins with the inclusion of header files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There are many header files available in the C++ programming language.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;So, what are these header files? The names of program elements such as variables, functions, classes, and so on must be declared before they can be used.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For example, you can’t just write x = 42 without first declaring variable x as:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;The declaration tells the compiler whether the element is &lt;strong&gt;an int, a double, a float, a function, or a class&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Similarly, header files allow us to put &lt;strong&gt;declarations&lt;/strong&gt; in one location and then import them wherever we need them.&lt;/p&gt;

&lt;p&gt;This saves a lot of typing in multi-file programs.&lt;/p&gt;

&lt;p&gt;To declare a header file, we use the &lt;strong&gt;#include&lt;/strong&gt; directive in every &lt;strong&gt;.cpp file&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This #include is used to ensure that they are not inserted multiple times into a single .cpp file.&lt;/p&gt;

&lt;p&gt;Now, moving forward to the code:&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;iostream&lt;/strong&gt; stands for &lt;strong&gt;Input/Output stream&lt;/strong&gt;, meaning this header file is necessary to take input through the user or print output to the screen. This header file contains the definitions for the functions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;cin&lt;/strong&gt;: used to take input&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;cout&lt;/strong&gt;: used to print output&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;namespace&lt;/strong&gt; defines which input/output form is to be used. You will understand these better as you progress in the course.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: &lt;strong&gt;semicolon (;) is used for terminating a C++ statement.&lt;/strong&gt; i.e., different statements in a C++ program are separated by a semicolon.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  main() function
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="n"&gt;Statement&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="n"&gt;Statement&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="p"&gt;...&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;int main()&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;int&lt;/strong&gt;: This is the &lt;strong&gt;return type&lt;/strong&gt; of the function. You will get this thing clear once you learn about Functions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;main()&lt;/strong&gt;: This is the portion of any C++ code inside which all the &lt;strong&gt;commands&lt;/strong&gt; are written and executed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This is the line at which the program will &lt;strong&gt;begin executing&lt;/strong&gt;. This statement is similar to the &lt;strong&gt;start block&lt;/strong&gt; of flowcharts.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;{}&lt;/strong&gt;: All the code written inside the curly braces is said to be in &lt;strong&gt;one block&lt;/strong&gt;, also known as a particular function scope. Again, things will be clear once you learn about Functions&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Compiler and Run
&lt;/h3&gt;

&lt;p&gt;For compiling and running a CPP program in Linux following are the command lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="nl"&gt;Compile:&lt;/span&gt; &lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="n"&gt;Filename&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cpp&lt;/span&gt; 
&lt;span class="n"&gt;Run&lt;/span&gt; &lt;span class="n"&gt;or&lt;/span&gt; &lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For compiling and running a CPP program in Windows following are the command lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="nl"&gt;Compile:&lt;/span&gt; &lt;span class="n"&gt;gcc&lt;/span&gt; &lt;span class="n"&gt;Filename&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cpp&lt;/span&gt; 
&lt;span class="n"&gt;Run&lt;/span&gt; &lt;span class="n"&gt;or&lt;/span&gt; &lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;filename&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Macros and Comments in C++&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Macros in C++&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Macros are a piece of code in a program that is given some name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Whenever the compiler encounters this name, the compiler replaces the name with the actual piece of code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The '#define' directive is used to define a macro.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Note: There is no semicolon(:) at the end of the macro definition.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt; &lt;span class="n"&gt;pace&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;//macro definition&lt;/span&gt;
&lt;span class="cp"&gt;#define LIMIT 5
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;LIMIT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="cm"&gt;/*    Output:
      e1 2 3 4     */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Macros with arguments:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We can also pass arguments to macros.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Macros defined with arguments work similarly as functions. Example:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include 
&lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="n"&gt;Std&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// macrO wth parameter &lt;/span&gt;
&lt;span class="cp"&gt;#define Area(l, b)(* b) 
&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
    &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"The Area of the rectangle is: "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="cm"&gt;/*    Output:
      The area of the rectangle is: 50    */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Comments in C++&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;C++ comments are hints that a programmer can add to make their code easier to read and understand.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;They are completely ignored by C++ compilers.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are two ways to add comments to code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;// - Single Line Comment&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;/* */ - Multi-line Comments&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example: Single-line comment&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt; &lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// This is a comment &lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"Hello World! "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/*    Output:
      Hello World    */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example: Multi-line comment&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt; &lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cm"&gt;/* This is a comment will print
    Hello World*/&lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"Hello World! "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/*    Output:
      Hello World    */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you have read this far... Do not forget to stay tuned for Part 2 of this series.&lt;br&gt;&lt;br&gt;
Thank you for reading 👋&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>cpp</category>
    </item>
  </channel>
</rss>
