C – Language

C provides several numeric data types for storing numbers — both whole numbers (integers) and decimal numbers (floating point).

🔹 1. int — Integer Type

Used to store whole numbers (no decimal point).

🧩 Example:

#include <stdio.h>

int main() {

    int myNum = 1000;

    printf(“%d”, myNum);

    return 0;

}

✅ Output:

1000

📘 Details:

  • Size: usually 2 or 4 bytes
  • Range: roughly -32,768 to 32,767 (for 2-byte) or -2 billion to +2 billion (for 4-byte)
  • Format specifier: %d or %i
  1. float — Single Precision Decimal

Used to store decimal numbers (floating-point values). 

🧩 Example:

#include <stdio.h>

int main() {

    float myNum = 5.75;

    printf(“%f”, myNum);

    return 0;

}

✅ Output:

5.750000

📘 Details:

  • Size: 4 bytes
  • Precision: about 6–7 digits after the decimal point
  • Format specifier: %f
  1. double — Double Precision Decimal

Used to store larger or more precise decimal numbers.

🧩 Example:

#include <stdio.h>

 

int main() {

    double myNum = 19.99;

    printf(“%lf”, myNum);

    return 0;

}

✅ Output:

19.990000

📘 Details:

Size: 8 bytes

Precision: about 15 digits after the decimal point

Format specifier: %lf

⚖️ float vs double

Feature

float

double

Size

4 bytes

8 bytes

Precision

~6–7 digits

~15 digits

Speed

Faster

Slightly slower

Use when

Less memory, okay with small precision

Need high precision (recommended)

🧠 Tip:
Prefer double for most mathematical and scientific calculations because it’s more accurate.

🧩 Quick Summary Table

Type

Size

Range / Precision

Format Specifier

Example

int

2–4 bytes

Whole numbers

%d

int x = 42;

float

4 bytes

~6–7 decimal digits

%f

float y = 3.14;

double

8 bytes

~15 decimal digits

%lf

double z = 9.8765;

✅ Key Points to Remember

  • Use int for whole numbers.
  • Use float or double for decimals.
  • Prefer double for accuracy.
  • %d → integer, %f → float, %lf → double.
  • Scientific notation uses e or E.