C Language Fundamental Data Types: Int, Float, Char, Double

Posted on December 27, 2009

Fundamental / Basic / Primary Data Types in C Language

The fundamental data types are of following types:

Integer(int) data type:

Integers are whole numbers. They have no fractional parts. These integers are represented using int data type. Integers can be positive or negative. The integer variable consumes 2 bytes of memory in the code.

Example:

#include
Void main()
{
int num;
num=17;
}

Character(char) data type:

An identifier or a variable which is declared as a char becomes a character variable. The character variable consumes 1 byte of memory in the code.

Example:

#include
Void main()
{
char ch;
char ch1;
ch=’y’;
ch1=’n’;
}

Float(Decimal or Real Number ) data type:

An identifier declared as a float becomes a floating-point variable or a decimal number. Any number which is having a fractional part is known as a floating point variable.

Example:

#include
Void main()
{
float inch;
inch=9.5;
}

Double data type:

Double data type is also used for floating point numbers. But there is a difference in memory consumption. Float data type occupies 4 bytes of memory in the code whereas double occupies 8 bytes of memory i.e. twice as that of float.

Example:

#include
Void main()
{
double rupees;
rupees=6530000;
}

These  data types have some modifiers associated with it which we will be discussing in the next section.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay

Looking for a Fresher Job? Post Your Resume Free !!!

More Articles From "C Programming" Category

home | top

TopOfBlogs