C Data Types

C Tutorial

 C Data Types (Complete Tutorial: Beginner → Advanced)

In C Data Types define:

  • what kind of data a variable can store

  • how much memory it occupies

  • what operations can be performed

They are one of the most important fundamentals for programming, exams, and interviews.


 What is a Data Type?

A data type specifies the type of value a variable can hold.


 Classification of Data Types in C

They are divided into four main categories:

  1. Basic (Primitive) Data Types

  2. Derived Data Types

  3. User-Defined Data Types

  4. Void Data Type


 Basic (Primitive) Data Types

These are the core data types in C.

int – Integer

Stores whole numbers.

  • Size: usually 4 bytes

  • Range: −2,147,483,648 to 2,147,483,647


float – Floating Point

Stores decimal numbers (single precision).

  • Size: 4 bytes

  • Precision: ~6 digits


double – Double Precision

Stores large decimal numbers.

  • Size: 8 bytes

  • Precision: ~15 digits


char – Character

Stores single character.

  • Size: 1 byte

  • Stored as ASCII value


 Type Modifiers (Extended Data Types)

Used to modify range and size.

ModifierExample
shortshort int a;
longlong int b;
signedsigned char c;
unsignedunsigned int d;

 Derived Data Types

Derived from basic types.

 Array


 Pointer


 Function


 User-Defined Data Types

Created by programmers.

struct


union


enum


typedef


 Void Data Type

Represents no value.

 Function Returning Nothing

 Void Pointer

  •  Can point to any data type

 Boolean Data Type (C99)


 

 

  • true → 1

  • false → 0


 Size of Data Types (Example)


 


 Common Format Specifiers

Data TypeSpecifier
int%d
float%f
double%lf
char%c
string%s

Common Mistakes

  •  Using wrong format specifier
  •  Assuming same size on all systems
  •  Confusing float and double 
  •  Forgetting & in scanf()

 Interview Questions (Must Prepare)

  1. What are data types in Ity, ?

  2. Difference between int, float, and double

  3. What is derived data type?

  4. Difference between struct and union

  5. What is void data type?

  6. Size of char in C?


 Summary

  •  Data types define type, size & range of data
  •  It has basic, derived, and user-defined types
  •  Correct data type improves performance & safety
  •  Fundamental for DSA, system programming & interviews

You may also like...