<?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 Nimnaabeysinghe on Medium]]></title>
        <description><![CDATA[Stories by Nimnaabeysinghe on Medium]]></description>
        <link>https://medium.com/@nimnaabeysinghe01?source=rss-3a861b52af1a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*XJZ8bDCcykuKvCXT</url>
            <title>Stories by Nimnaabeysinghe on Medium</title>
            <link>https://medium.com/@nimnaabeysinghe01?source=rss-3a861b52af1a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 11:43:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nimnaabeysinghe01/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/@nimnaabeysinghe01/data-types-of-c-b27811e696b?source=rss-3a861b52af1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b27811e696b</guid>
            <dc:creator><![CDATA[Nimnaabeysinghe]]></dc:creator>
            <pubDate>Wed, 05 Oct 2022 16:37:50 GMT</pubDate>
            <atom:updated>2022-10-05T16:37:50.222Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*cmQiuo8yKfO7auXCeR8VxA.jpeg" /></figure><ul><li>C++ is one of most popular, powerful and general purpose programming language which used in the world. In each C++ variable has a specific data types which tells us the size, range and the types of a value that can be stored in a variable. Based on the data type assigned to a variable, the operating system allocates memory and decides what type of data is to be stored in the variable. This article is about more details of the data types of C++. So that, there are 2 main data types in C++. They are,</li><li><strong><em>1. Fundamental data types</em></strong></li><li><strong><em>2. User-defined data types</em></strong></li><li>Under above main two data types there are 7 data types which are belongs to fundamental and user-defined data types.</li></ul><p>Note : Let’s categorize 7 data types into 2 main data types.</p><h3>Fundamental data types</h3><ul><li>Fundamental data types are the data types which are predefined in the language and can be directly used to declare a variable in C++. And also we can say, fundamental data types are the data types which can represent data in a very simple nature. In other words, fundamental data types are basic types implemented directly by the language that represent the basic storage units supported natively by most systems. This data type also called primitive data types. These data types are not composed of any other data types. There are six data types which are belong to fundamental data types. They are,</li><li>1.short</li><li>2.int</li><li>3.float</li><li>4.double</li><li>5.bool</li><li>6.char</li></ul><p>Note : Let’s see more details about 6 fundamental data types.</p><ol><li><strong><em>short </em>data type</strong></li></ol><ul><li>Short data type can only handle smaller integers. Those can be positive or negative integer values. In shortly we can say, short data type is a single, positive or negative integer value. This data type can store(range) integer value from -32,768 to 32,767. Short data type allocates 2 bytes from the memory space to store integer value. This short data type was designed to store integer values of smaller range than an<em> </em>int<strong> </strong>data type.</li></ul><p>General form of short data type code in C++ —short variable_name=value;</p><p>For example, short s=10;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*xbaUq6k8-Bk19VEMGaidog.png" /></figure><blockquote>2.<strong> int <em>data type</em></strong></blockquote><p>.Int data type can also store only integer types of values. They can be positive or negative integers. But, this data type can store more integer values than short data type. Which means, the range of this data type is higher than the range of short data type. The range of int data type is from -2,147,483 to 2,147,483,647. This data type allocates 4 bytes from the memory space to store integer type of value.</p><p>General form of int data type in code in C++ — int variable_name=value</p><p>For example, int i=1000;</p><figure><img alt="A program of int data type and it’s output" src="https://cdn-images-1.medium.com/max/761/1*YXqxsfOCnrGg4ry3nG223w.png" /></figure><p>3.<strong> f<em>loat</em> data type</strong></p><p>.Float data type can store real numbers with 7 digits of precision. Which means this data type allows to store seven digits after the decimal point. We cannot store a real number with 8 digits after the decimal point. The range of this data type is real numbers from -3.4 x 10³⁸ to 3.4 x 10⁸. This data type allocates 4 bytes from the memory space to store real numbers with seven digits precision.</p><p>General form of float data type in code C++ — float variable_name=value</p><p>For example, float t=3.5764</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*gda909OHomaUeKrPJBvqUw.png" /></figure><p>4. d<strong><em>ouble </em>data type</strong></p><p>.Double data type can store real numbers with 15 digits precision. Which means, this data type allows to store fifteen digits after the decimal point. The range of this data type is real numbers from -1.7x10³⁰⁸ to 1.7x10³⁰⁸.This data type allocates 8 bytes from the memory space to store real numbers with fifteen digits precision. Double data type can store more real number that float data type as the range of double data type is higher than the range of float data type.</p><p>General form of double data type in C++ code-double variable_name=value</p><p>For example, double s=23.8976</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*wbEs3vZQECGkxiS4gagY5Q.png" /></figure><p>5<strong>.b<em>ool</em> data type</strong></p><p>. Bool data type is what programmers use to show logic in coding. This data type only store boolean values. There are 2 boolean values. They are, true and false. The response should be one of the above two values. This data type can be seen in if/when in programming functions. Which means, can be seen in selection structure programs. This data type directs the response, which determines the next code. Bool data type allocates only 1 byte from the memory space to store true or false value.</p><p>General form of bool data type in C++ code — bool variable_name=value</p><p>For example, bool c = true;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*WwkesLtbcOFZmSaY-x18Dg.png" /></figure><p>6. <strong>char data type</strong></p><p>.Char data type stores a single character. That character can be a single letter, a number or a special marks like #, @ , * etc. This character should be written within single quotes. This data type allocates only one byte from the memory space to store characters.</p><p>General form of char data type in C++ — char variable_name=value</p><p>For example, char n=’t’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*qQff0ILkXZlU6SaUmjNueA.png" /></figure><h3>User-defined data types</h3><p>.Those data types which are defined by the user as per his/her will are called user defined data types .These data types are constructed by using fundamental data types, such as short, int, char, bool, double, float. They cannot construct alone. Their should be a support in fundamental data types. Some user-defined data types include structures, union, class and enumerated. String data type is belong to this user- defined data type</p><p>Note: Let’s see more about string data type.</p><p><strong><em>string</em> data type</strong></p><p>. A string data type is a combination of character that can be either named constant or variable. This data type can include both upper and lower letters, numbers, punctuation marks. This data type sores zero or more characters. String values must be surrounded by double quotes. Sting data type is used for storing text strings. This data type allocates 1 byte per character by memory location to store string types of values.</p><p>General form of string data type in C++ — string variable_name=value</p><p>For example, string t=lik5,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*WbSxI1LZ-cVPll-2noys0w.png" /></figure><p>*So, in this article we discussed about a brief explanation about C++ language, what are the main two data types in C++?, then how can we categorize seven data types into two main data types, and also there were more details about data types in C++ one by one. So , I think this article will help you to understand data types information in C++.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b27811e696b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>