<?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/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									What is the difference between int, float, double, and char in C - C / C++				            </title>
            <link>https://www.hacktheforum.com/c-c/what-is-the-difference-between-int-float-double-and-char-in-c/</link>
            <description>Hack The Forum Discussion Board</description>
            <language>en</language>
            <lastBuildDate>Mon, 11 May 2026 03:04:47 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>What is the difference between int, float, double, and char in C</title>
                        <link>https://www.hacktheforum.com/c-c/what-is-the-difference-between-int-float-double-and-char-in-c/#post-891</link>
                        <pubDate>Sun, 16 Mar 2025 15:45:56 +0000</pubDate>
                        <description><![CDATA[In C, int, float, double, and char are different data types used to store different kinds of values. Here&#039;s a breakdown of the differences:
1. int (Integer):

Purpose: Used to store whole...]]></description>
                        <content:encoded><![CDATA[<p data-start="0" data-end="147">In C, <code data-start="6" data-end="11">int</code>, <code data-start="13" data-end="20">float</code>, <code data-start="22" data-end="30">double</code>, and <code data-start="36" data-end="42">char</code> are different data types used to store different kinds of values. Here's a breakdown of the differences:</p>
<h3 data-start="149" data-end="176">1. <strong data-start="156" data-end="175"><code data-start="158" data-end="163">int</code> (Integer)</strong>:</h3>
<ul data-start="180" data-end="605">
<li data-start="180" data-end="267"><strong data-start="182" data-end="193">Purpose</strong>: Used to store whole numbers (i.e., integers without any decimal points).</li>
<li data-start="271" data-end="369"><strong data-start="273" data-end="281">Size</strong>: Typically 4 bytes on most systems (but can vary depending on the system architecture).</li>
<li data-start="373" data-end="549"><strong data-start="375" data-end="384">Range</strong>: The range of values <code data-start="406" data-end="411">int</code> can hold depends on the system, but generally, it is from -2,147,483,648 to 2,147,483,647 for a 4-byte <code data-start="515" data-end="520">int</code> (using 32-bit architecture).</li>
<li data-start="553" data-end="605"><strong data-start="555" data-end="566">Example</strong>:
<div class="contain-inline-size rounded-md border- border-token-border-medium relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none rounded-t-">
<pre contenteditable="false">int num = 5;</pre>
</div>
</div>
</li>
</ul>
<h3 data-start="607" data-end="650">2. <strong data-start="614" data-end="649"><code data-start="616" data-end="623">float</code> (Floating-point number)</strong>:</h3>
<ul data-start="654" data-end="1021">
<li data-start="654" data-end="795"><strong data-start="656" data-end="667">Purpose</strong>: Used to store numbers with a fractional part (decimals). It is used when precision is not as critical, and space is a concern.</li>
<li data-start="799" data-end="839"><strong data-start="801" data-end="809">Size</strong>: Typically 4 bytes (32 bits).</li>
<li data-start="843" data-end="962"><strong data-start="845" data-end="854">Range</strong>: Can store numbers from approximately 1.5 × 10⁻⁴⁵ to 3.4 × 10³⁸ with about 6-7 decimal digits of precision.</li>
<li data-start="966" data-end="1021"><strong data-start="968" data-end="979">Example</strong>:
<div class="contain-inline-size rounded-md border- border-token-border-medium relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none rounded-t-">
<pre contenteditable="false">float pi = 3.14;</pre>
</div>
</div>
</li>
</ul>
<h3 data-start="1023" data-end="1084">3. <strong data-start="1030" data-end="1083"><code data-start="1032" data-end="1040">double</code> (Double-precision floating-point number)</strong>:</h3>
<ul data-start="1088" data-end="1466">
<li data-start="1088" data-end="1222"><strong data-start="1090" data-end="1101">Purpose</strong>: Used for storing floating-point numbers with greater precision than <code data-start="1171" data-end="1178">float</code>. It is used when more accuracy is required.</li>
<li data-start="1226" data-end="1266"><strong data-start="1228" data-end="1236">Size</strong>: Typically 8 bytes (64 bits).</li>
<li data-start="1270" data-end="1393"><strong data-start="1272" data-end="1281">Range</strong>: Can store numbers from approximately 5.0 × 10⁻³²⁷ to 1.7 × 10³⁰⁷ with about 15-16 decimal digits of precision.</li>
<li data-start="1397" data-end="1466"><strong data-start="1399" data-end="1410">Example</strong>:
<div class="contain-inline-size rounded-md border- border-token-border-medium relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none rounded-t-">
<pre contenteditable="false">double pi = 3.141592653589793;</pre>
</div>
</div>
</li>
</ul>
<h3 data-start="1468" data-end="1498">4. <strong data-start="1475" data-end="1497"><code data-start="1477" data-end="1483">char</code> (Character)</strong>:</h3>
<ul data-start="1502" data-end="1867">
<li data-start="1502" data-end="1569"><strong data-start="1504" data-end="1515">Purpose</strong>: Used to store a single character (usually one byte).</li>
<li data-start="1573" data-end="1611"><strong data-start="1575" data-end="1583">Size</strong>: Typically 1 byte (8 bits).</li>
<li data-start="1615" data-end="1806"><strong data-start="1617" data-end="1626">Range</strong>: Can store values from -128 to 127 (signed) or 0 to 255 (unsigned) if used as a numeric type. When used as a character, it represents a single character, e.g., 'A', 'b', '3', etc.</li>
<li data-start="1810" data-end="1867"><strong data-start="1812" data-end="1823">Example</strong>:
<div class="contain-inline-size rounded-md border- border-token-border-medium relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none rounded-t-">
<pre contenteditable="false">char letter = 'A';</pre>
</div>
</div>
</li>
</ul>
<h3 data-start="1869" data-end="1900"> </h3>]]></content:encoded>
						                            <category domain="https://www.hacktheforum.com/c-c/">C / C++</category>                        <dc:creator>kajal</dc:creator>
                        <guid isPermaLink="true">https://www.hacktheforum.com/c-c/what-is-the-difference-between-int-float-double-and-char-in-c/#post-891</guid>
                    </item>
							        </channel>
        </rss>
		