In the following article we are are discussing about basic data types in c and primitive data types in c. All information related to basic data types in c are given in detail along with examples. All the basic data types in c are explained along with programmatic explanation.
Basic data types in C:
- Data type is nothing but what type of data values which you are stored for the variable in the program.
- C programming provides various types of data-types.
- Data type provides type for the variable to which we are stored in program for processing.
- It is the collection of data with values having fixed meaning as well as characteristics.
- There are various types and some of them are an integer, floating point, character, etc.
- Data type specifies the range values for given data-type.
What is the use of C:
- When we declare any variable data type is helpful for identifying the type of a variable.
- In the recursive function data type is used to identify the type of the return value of that function.
- Also in function definition and function declaration it is used to identify the type of a parameter expected by a function.
Types of data types:
It provides three types of data types:
1. Built-in Data Types:
void, int, char, double and float.
2. Derived Data Types:
Array, References, and Pointers.
3. User Defined Data Types:
Structure, Union, and Enumeration.
1. Built-in Data Types:
C program supports following primary data types:
- void: It holds no value and is generally used for specifying the type of function or what it returns.
Function will not return any value when it is declared as void.
- Int: It denotes an integer type.
- Char: It denotes a character type.
- float, double: It denotes a floating point type.
- int *, float *, char * : It denotes a pointer type.
Example:
int weight;
char gender;
float length, width;
2. Derived data types:
It contains following derived data types:
- Arrays: It is a sequence of data items having homogeneous values which have adjacent memory locations to store values.
- References: Function pointers allow referencing functions with a particular signature.
- Pointers: These are powerful C features which are used to access the memory and deal with their addresses.
3. User Defined data types:
C programming allows the programmers to define their choice of identifier that represent an existing data type which is having three such types:
- Structure: It stores different types of data type values under a single name. Keyword: “struct”.
- Union: It is used for storing various data types in the same memory location. Keyword: “union”.
- Enum: Special data type that consists of integral constants and each of them is assigned with a specific name. Keyword: “enum”.
Example:
#include<stdio.h>
#include<conio.h>
#include<limits.h>
void main()
{ struct student { int rno;
char gender;
} s1;
printf(“Storage size for Integer data type is: %d \n”, sizeof(int));
printf(“Storage size for character data type is: %d \n”, sizeof(char)); printf(“Storage size for character data type is: %d \n”, sizeof(struct));
getch();
}
Related Articles:
- Basic Accounting Concepts Part 1
basic data types in cdata types in c languagedata types in c with examplesderived data types in cdouble data type in cenumerated data type in clong int in cprimitive data types in csize of data types in ctypedef struct ctypes of data types in cuser defined data types in c
Basic data types in c | Primitive data types in c
2022-11-16
Computer Basics
No Comments
Admin
In the following article we are are discussing about basic data types in c and primitive data types in c. All information related to basic data types in c are given in detail along with examples. All the basic data types in c are explained along with programmatic explanation.
Basic data types in C:
What is the use of C:
Types of data types:
It provides three types of data types:
1. Built-in Data Types:
void, int, char, double and float.
2. Derived Data Types:
Array, References, and Pointers.
3. User Defined Data Types:
Structure, Union, and Enumeration.
1. Built-in Data Types:
C program supports following primary data types:
Function will not return any value when it is declared as void.
Example:
int weight;
char gender;
float length, width;
2. Derived data types:
It contains following derived data types:
3. User Defined data types:
C programming allows the programmers to define their choice of identifier that represent an existing data type which is having three such types:
Example:
#include<stdio.h>
#include<conio.h>
#include<limits.h>
void main()
{ struct student { int rno;
char gender;
} s1;
printf(“Storage size for Integer data type is: %d \n”, sizeof(int));
printf(“Storage size for character data type is: %d \n”, sizeof(char)); printf(“Storage size for character data type is: %d \n”, sizeof(struct));
getch();
}
Related Articles:
Some More: DBMS/ WT/ DMDW
basic data types in cdata types in c languagedata types in c with examplesderived data types in cdouble data type in cenumerated data type in clong int in cprimitive data types in csize of data types in ctypedef struct ctypes of data types in cuser defined data types in c