Data Types in C with Examples


Data Types in C with Examples

There are four basic data types in C language. They are given below along with the number of bytes occupied by them in the computer memory. (RAM)

Data TypeBytes Occupied in RAMValue RangeValue Range in Decimal
char1 byte-27 to 27-1-128 to 127
int2 bytes-215 to 215 -1-32768 to 32767
float4 bytes-231 to 231 -13.4e38 to 3.4e+38
double8 bytes-263 to 263 -11.7e-308 to 1.7e+308


Note that the value range is calculated from the number of bits occupied by the data type. For example, int uses two bytes i.e. 16 bits; from this 1 bit is taken for sign (- or +). So, the range is expressed as -2 to the power 15 to 2 to the power 15-1. (Its decimal equivalent can be calculated by using a calculator but in the case of double, the calculator gives inaccurate answers since they are designed only to handle a small range of values.

Read also, Generation of Computers with their characteristics

The four basic data types in C language are defined as follows

  • Char:- It refers to the character. It can hold one letter and symbol. In fact, the character in c is associated with integers to refer to a letter/symbol as per ASCII( American Standard Code for Information Interchange) that has assigned integer value for all letters/symbols used in programming.
  • int:- This refers to an integer value. This is used to represent the signed or unsigned whole number within a specific range.
  • float:- This refers to a floating-point or real number. It is used to represent a real number like 3.174813 or 4.52e6 with six decimal digits in decimal or exponential form.
  • double:- This also refers to floating-point or real number. It can hold a real number in double precision. A double-precision number is used to represent 12 decimal digits like 3.412587632156 or 4.52145342148e12.

C language has additional data types along with the basic data types to enable the users to declare a variable in an appropriate type to improve the program execution speed and to refer to the largest and smallest numbers possible in programming for science and engineering applications.

Data TypeBytes Occupied in RAMValue Range The range of values referred
unsigned char1 byte0 to 28-10 to 255
short int1 byte-27 to 27-1-128 to 127
unsigned short int1 byte0 to 28-10 to 255
unsigned int2 bytes0 to 216-10 to 65535
long int4 bytes-231 to 231-1-2,147,483,648 to 2,147,483,647
unsigned long int4 bytes0 to 232-10 to 4,294,967,295
long double10 bytes-279 to 279-13.4e-4932 to 1.1e+4932

Example of C data types

#include <stdio.h>

int main() {
  // Create variables
  int integerNumber = 10;               // Integer number
  float floatingNumber = 10.99;     // Floating point number
  char cahracterNumber = 'E';         // Character
  
  // Print variables
  printf("%d\n", integerNumber );
  printf("%f\n", floatingNumber );
  printf("%c\n", cahracterNumber );
  return 0;
}

Output:-

10
10.99
E

Conclusion:- I hope this tutorial will help you to understand the overview of data types. If there is any doubt then please leave a comment below.


Leave a Comment

RATU311

RATU311

THOR311

parlay

CERI188

HOKI311

RATU311

RATU311

judi bola online

Mix Parlay

THOR311

Ceri188

Thor311 Game Online

Thor311 Aplikasi

LINK CERI188

RATU311 NONTON BOLA

RATU311

HOKI311 Link Alternatif

CERI188 Link RTP LIVE

THOR311

THOR311

Thor311 Live Casino

CERI188

akses VIP THOR311

THOR311

link daftar THOR311

THOR311

situs thor311

THOR311 LOGIN

THOR311

THOR311

THOR311

RATU311

RATU311

HOKI311 Link SABUNG AYAM RESMI

HOKI311 Link QRIS EWALLET

RATU311

LINK CERI188

parlay

HOKI311 Link RTP Gacor

THOR311

RATU311

THOR311

THOR311

HOKI311 Link Apk Resmi

RATU311

KUPU178

RATU311

RATU311

RATU311

CERI188

CERI188 Situs Spaceman Terbaik 2026

KUPU178 Link Daftar

CERI188

CERI188

CERI188

CERI188

CERI188

HOKI311

THOR311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

CERI188 Live Casino

HOKI311 Lapak Arena Slot

RATU311 judi bola

CERI188 Live Casino

HOKI311 Link Spaceman Online

RATU311

HOKI311 Link Daftar Resmi

CERI188 Toto SGP Online

KUPU178

KUPU178

KUPU178

KUPU178

HOKI311 TEMBAK IKAN ONLINE

RATU311

CERI188 PANDUAN MAXWIN SLOT ONLINE

RATU311

RATU311

RATU311

KUPU178

HOKI311 Link Login Alternatif

HOKI311 Live Casino Online

HOKI311 Situs Slot Gacor

THOR311

THOR311

situs judi bola

THOR311

Ceri188 Game Online

CERI188

link login CERI188

THOR311

link login CERI188

CERI188

link login CERI188

link login CERI188

link daftar CERI188

THOR311

HOKI311

HOKI311

CERI188

CERI188

CERI188

parlay

THOR311

RATU311

RATU311

HOKI311

HOKI311

parlay

HOKI311

RATU311

THOR311

KUPU178

HOKI311

KUPU178

KUPU178

KUPU178

HOKI311

parlay

slot gacor

kupu178 link alternatif

kupu178 slot

kupu178 daftar

kupu178 login

link daftar kupu178

judi bola

HOKI311

RATU311

link alternatif RATU311

Link daftar RATU311

link login RATU311

RATU311

RATU311

RATU311

RATU311

KUPU178

KUPU178

KUPU178

THOR311

KUPU178

KUPU178

KUPU178

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

THOR311

RATU311

KUPU178

KUPU178

HOKI311

THOR311

KUPU178

THOR311

THOR311

slot thailand

judi bola

THOR311

THOR311

KUPU178

THOR311

situs bola

THOR311

slot gacor

slot gacor

yakuza303

slot gacor

unobet77

slot gacor

slot gacor

RATU311

parlay

parlay

slot gacor

mix parlay

judi bola

judi bola

mix parlay

parlay

judi bola

sv388

judi bola

judi bola

judi bola

parlay

THOR311