<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rijas Mohamed on Medium]]></title>
        <description><![CDATA[Stories by Rijas Mohamed on Medium]]></description>
        <link>https://medium.com/@rijas_mohamed?source=rss-e5ea09f0f54e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*OGkKq-od2oAYomTu</url>
            <title>Stories by Rijas Mohamed on Medium</title>
            <link>https://medium.com/@rijas_mohamed?source=rss-e5ea09f0f54e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 11:14:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rijas_mohamed/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Data Types of C++]]></title>
            <link>https://medium.com/@rijas_mohamed/data-types-of-c-7f12d1462187?source=rss-e5ea09f0f54e------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f12d1462187</guid>
            <dc:creator><![CDATA[Rijas Mohamed]]></dc:creator>
            <pubDate>Tue, 04 Oct 2022 06:09:05 GMT</pubDate>
            <atom:updated>2022-10-05T17:55:25.692Z</atom:updated>
            <content:encoded><![CDATA[<p>A programming language cannot work without a wide range of data types as each type has its own significance and utility to perform various tasks. Here, reasons are mentioned why we require different data types in C and C++ Programming:</p><ul><li>At the time of the variable declaration, it becomes convenient for the user to distinguish which type of data variable stores.</li><li>It makes it clear for the user to identify the return value of the function based on the data type.</li><li>If parameters are passed to the function, it becomes easy for the user to give input according to the given format.</li></ul><p>This is just the beginning, at the end of this article, you will be an expert in Data Types in C and C++ with tested knowledge.</p><h3>1. What is Data Type in C/C++?</h3><p>Data types in C and C++ refer to the <em>characteristics of data stored into a variable</em>. For instance, while working with mathematical problems, in order to simplify things for us, we look for a specific type of data, let’s say, we want to find the factorial of a number. We know that only for whole numbers, the factorial of that number exists which is also a whole number. In order to eliminate all scopes of errors and reduce run-time of the program, we would preferably assign such a data type to the input and output such that it only covers the range of whole numbers. This is how you begin to think to increase your program efficiency and well utilize the features offered by C.</p><p>Clearly, from the above discussion, you might have inferred that memory occupied by different data types would be different. Therefore, a different amount of space in the computer memory would be allocated for them and hence the run time of the program would be reduced, increasing the efficiency of the program.</p><h3>Definition of Data Types</h3><p>we need to use different variables to store different information. Variables are just storage locations reserved for storing values. Therefore when you create the variable, you reserve some space in memory. You may want to store information for different data types, such as integers, floats, strings, and Boolean values. Memory is allocated based on the variable’s data type. The amount of memory required depends on the data type.</p><p>score here is an int datatype variable. The variable score can only store 2-byte or 4-byte integers, depending on the compiler/system.</p><p><strong>In C++, data types can be classified as follows:</strong></p><ol><li>Fundamental Datatypes</li><li>Derived Datatypes</li><li>User-defined Datatypes</li></ol><h3>Fundamental Data types in C++</h3><p>Users can use the primitive data types to declare variables, and these are built-in data types in C++, for instance, float, bool, etc. Primitive data types present in C++ are defined below;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ueODUD5ftsAR8CRQItBwig.jpeg" /></figure><h3>1. Short</h3><p>Short is a data type that allows you to insert small integer values to a variable. It uses 2 byets for a variable. so, if we insert a value between -32767 to 32767 we can this data type.</p><p>For Example,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5x170AbMF6bDytyW-fBJrw.jpeg" /></figure><h3>2. Integer</h3><p>The keyword int can represent integer data types. The range of integers is -2147483648 to 2147483647, and they take up 4 bytes of memory.</p><p>For example,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gqZHdMUv4xfwPkk5ia0s3A.png" /></figure><p>data here is an integer data type variable. The variable data requires 2 or 4 bytes of memory space.</p><h3>3. Character</h3><p>The keyword char represent characters. It is 1 byte in size. Single quotes ‘ ‘ are used to enclose characters in C++.</p><p>For example,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GZ-RVjZziRwaDoy93J9LHQ.png" /></figure><p>ch here is a character datatype variable. This means that the variable requires 1 byte of memory space.</p><h3>4. Boolean</h3><p>The boolean data type’s keyword is bool. True or false are the two possible values for the boolean data type. Boolean values are generally used in conditional statements and loops.</p><p>For example<em>,</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*56FiCKvXeHdOMI4B_k7WtQ.png" /></figure><p>Example 2;</p><p><em>bool is_true = true;</em></p><p>is_true here is a boolean data type variable. This means that the variable requires 1 byte of memory space.</p><h3>5. Floating Point</h3><p>float is the keyword used to hold floating-point numbers (decimals and exponentials). The float variable has a size of 4 bytes.</p><p>For example,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qXKUNLkm7xWqKSwR5gfu8A.png" /></figure><p>val here is a floating-point datatype variable. This means that the variable requires 4 bytes of memory space.</p><h3>6. Double Floating Point</h3><p>double is the keyword used to hold floating-point numbers (decimals and exponentials) with double precision. The double variable has a size of 8 bytes.</p><p>For example,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yylqxrbiL_TqbgmiXoPL0w.png" /></figure><p>val here is a double floating-point datatype variable. This means that the variable requires 8 bytes of memory space.</p><h3>User-Defined Data types in C++</h3><p>String data type is used to store sequence characters like text. We need to insert the string value withing the quotation marks (“ Hello ”).More memory can be allocated at run time on demand. No memory pre allocation, no memory is wasted.</p><p>(‘a’ is a char and “a” is a string)</p><p>User defined types are NOT variables. You still must declare variables to use the type. In order for types to be useful throughout your program, define the type in global scope.</p><p>The following table shows the summary for the variable type, how much memory it takes to store the value in memory, and what is maximum and minimum value, which can be stored in such type of variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8n_ldPs5M1DuWy0TOF1SLg.jpeg" /></figure><p>The following coding shows the example for all Data type. it’s shows that how to define a data type and what are the outputs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QZjYkC4UQqGOf7RP2AAfmQ.png" /><figcaption><strong>Exmaple for all Data types</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BG6Sr3ZLDDjy8SC2wnZV5w.png" /><figcaption><strong>output for that exmaples</strong></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f12d1462187" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>