Code Point Blog

Iam presenting here ,all type of knowledge if you want to interest knowing about any topic then click below thumbnail view button and knowing.

All Chapter Back to Home Page

Data type in C language

They are an essential part of any programming language, including C, and are used to define the type and size of data that variables can hold. Here are some common data types in C:


1.Basic Data Types :

int :Integer type, used for whole numbers.

float :Floating-point type, used for single-precision floating-point numbers.

double :Double-precision floating-point type, used for double-precision floating-point numbers.

char :Character type, used for storing single characters.


2.Modifier Data Types:

short :Short integer type, typically smaller than `int`.

Long :Long integer type, typically larger than `int`.

unsigned : Used to represent non-negative values of basic data types.

signed : Used to represent both positive and negative values of basic data types (default for `int`).


Derived Data Types :

Array :Collection of elements of the same data type.

struct : User-defined data type that groups different data items together.

union :Similar to `struct`, but all members share the same memory location.

enum :Enumeration data type, used to define named constants.

Here's an example of using some basic data types in C:

                
                #include <stdio.h>
                    int main() {
                        int age = 25;
                        float pi = 3.14159;
                        char grade = 'A'; 
        
                        printf("Age: %d\n", age);
                        printf("Pi: %.2f\n", pi); 
                        printf("Grade: %c\n", grade); 
        
                        return 0;
                        } 
        
                        Output: 
                        Age: 25 
                        Pi: 3.14 
                        Grade: A