Data type in c language
In c language data type provide declaration of variable determines size of data that are assigned by a variable.
In c language there are two different data types
- Primary data types
- Derived data types
Description
Data type in c language
- Primary data types: there is main three primary data types
- 1. integer(written in program as int)
- 2. floating point(written in program as float)
- 3. character data types(written in program as char)
- 4. and one is void data type(this data type is non return value data type it means it execute program in own function it cannot return value to another function example is void main() is a main function where from start the program)
Type | Size(bytes) | Range |
int or signed int data type | 2 bytes | Between -32,768 to 32767 |
unsigned int data type | 2 bytes | Between 0 to 65535 |
short int or signed short int data type | 1 bytes | Between -128 to 127 |
unsigned short int data type | 1 bytes | Between 0 to 255 |
long int or signed long int data type | 4 bytes | Between -2,147,483,648 to Between 2,147,483,647 |
unsigned long int data type | 4 bytes | Between 0 to 4,294,967,295 |
Type | Size (bytes) | Format Specified |
Int data type | at least 2, usually 4 | %d, %i use for input integer value and output integer value |
2. float data types
Type | Size(bytes) | Range |
Float (floating point data type) | 4 bytes | Between 3.4E-38 to 3.4E+38 |
double (floating point data type) | 8 bytes | Between 1.7E-308 to 1.7E+308 |
long double (floating point data type) | 10 bytes | Between 3.4E-4932 to 1.1E+4932 |
Float in c language | %f code is use to input value and print value | |
double | %lf code is use to input value and print value | |
long double | %Lf code is use to input value and print value |
3. Character data types in c language
char or signed char in c language | 1 | -128 to 127 |
unsigned char in c language | 1 | 0 to 255 |
signed char in c language | 1 | %c code is use to input character value and print character value |
4. Void data type means no value return type of function
Such as example
#include<stdio.h>
#include<conio.h>
Void main()
{
Program code…
getch();
}
Int type return a integer value in function
Such as example
#include<stdio.h>
#include<conio.h>
int main()
{
Program code..
return 0; //this return statement must be included when you use int in main function.
}
- Derived data types
In derived data type array, pointer, function, structure etc. are used.
We will learn about derived data types in later post when we use array program, how to create array program, what is pointer in c language, use of c language pointer, what is function in c language, types of function in c language, how to define a function in c language, what is structure in c language, how to create structure program in c language, etc…
Some example of primary data types
Use of integer data types
int a, b;
syntax:
datatypes variable_name
floating points datatypes
float marks;
double salary;
syntax:
datatypes variable_name
character datatypes
char grade = ‘A’;
syntax:
datatypes variable_name = ‘value’
we learnt about Data type in c language
1 Comment
kumar · at
hi,
best computer software C/C++ details sharing with us , keep it up