C Data Types Examples

C Tutorial

 C Data Types – Examples (Beginner → Practical)

In C language, data types specify what kind of data a variable can store, how much memory it uses, and what operations are allowed on it.

Below are clear examples of all major C data types, exactly the way they are asked in exams & interviews.


 Basic (Primitive) Data Types


int – Integer Data Type

Stores whole numbers.


 

 Size: usually 4 bytes


float – Floating Point

Stores decimal numbers (single precision).


 

 Size: 4 bytes


double – Double Precision Float

Stores large decimal values with high precision.


 

 Size: 8 bytes


char – Character Data Type

Stores single character.


 

 Size: 1 byte
 Stored internally as ASCII value


 Derived Data Types


 Array Example


 

  •  Stores multiple values of same type

 Pointer Example


 

  •  Stores address of variable

 Structure Example


 

  •  Stores different data types together

 Union Example


 

  •  Shares same memory location

 Enumeration (enum) Data Type


 

  •  Used for named integer constants

void Data Type

 Function Returning Nothing

void Pointer

  •  Represents no type

 Type Modifiers (Extended Data Types)


short, long, signed, unsigned

  •  Modify range & size

 Boolean Type (stdbool.h)


 

  • true → 1
  • false → 0

 Size of Data Types (Example)


 


 Interview-Focused Summary Table

Data TypeExampleUse
intint a = 10;Numbers
floatfloat x = 1.5;Decimals
doubledouble d = 2.5;Precision
charchar c = 'A';Characters
arrayint a[5];Multiple values
structstruct S {}Mixed data
pointerint *p;Memory address
enumenum DayConstants
voidvoid func()No return

 Common Mistakes

  • Using wrong format specifier

  • Confusing float and double

  • Forgetting & in scanf()

  • Assuming same size on all systems


 Final Summary

  •  Data types define type, size & range of data
  •  C has basic, derived, and user-defined types
  •  Choosing correct data type improves performance & safety
  •  Very important for exams, interviews & real projects

You may also like...