Data Types in C Programming Language

Notes:

Data Types in C Programming Language

Data type:
The name itself indicating, data type means type of data.

Game:
playerScore= 10; // playerScore is integer type of data
gravity =9.8; // gravity is real type of data
re-play=’y’; // replay is character type of data

Banking application:
accountNumber=10; // accountNumber is integer type of data
rateOfInterest=13.5; // rateOfInterest is real type of data
hasLoan=’y’; // hasLoan is character type of data

Types of data types:
There are 2 types of data types in C.
1. Primitive or basic
2. Non primitive or derived or composite or complex

Primitive data types:
1. int (%d or %i): Integer (whole) numbers: (numbers without floating point)
Ex: 22, -44, 2017, etc.
2. float (%f, %e): single precision real numbers (6 to 7)
Ex: 3.142, 9.8, 2.123456, 3.4E+38
3. double (%lf): double precision real numbers(15 to 16)
Ex: 3.142, 9.8, 2.1234567898765, 1.7E+308
4. char (%c): any symbol from the ASCII chart enclosed in between single quotes
Ex: ‘A’, ‘9’, ‘$’, ’\n’, ‘\t’
5. void: no value
Ex: nothing

Non -primitive data types:
array: represents list of data values
pointer: represents a reference of another memory location
structure: represents a record
union: represents a record

Example Code:
#include <stdio.h>
#include<float.h>
int main()
{
printf("Manjunath%s"," Chidre\n");
printf("The sum of %i and %i is=%i\n",3,4,3+4);
printf("float precision is=%i\n",FLT_DIG);//6
printf("double precision is=%i\n",DBL_DIG);//15
printf("long double precision is=%i\n",LDBL_DIG);//18
return 0;
}