Skip to main content

Command Palette

Search for a command to run...

7.Data Types in C Programming

Explanation of Data Types with Small Code Snippets

Updated
โ€ข1 min readโ€ขView as Markdown
7.Data Types in C Programming

What Is a Data Type?

A data type tells the compiler:

  • The type of data a variable will store

  • The size of memory required

  • The range of values the variable can hold

Basic Data Types :

๐Ÿ”น int

  • Used to store whole numbers

int number = 10;

printf("%d", number);

๐Ÿ”น char

  • Used to store single characters

char grade = 'A';

printf("%c", grade);

๐Ÿ”น float

  • Used to store decimal (real) numbers

float temp = 36.5;

printf("%.1f", temp);

๐Ÿ”น double

  • Used to store large decimal numbers

  • More precise than float

double average = 89.4567;

printf("%lf", average);

๐Ÿ”น void

  • Represents no value

  • Used when no data is required

Example C Program Using Different Data Types