Data Types of C language

Safalta Expert Published by: Saksham Chauhan Updated Wed, 22 Feb 2023 06:33 PM IST

Highlights

Check the Data Types of C language Here At Safalta.com

In our previous blog we learn about the introduction of C Programming, In this blog we will get to know about the Data Types Of C language. For the previous blog you can check the link below 'Introduction of C Programming'. Data types define the semantics and properties of data element storage in the C programming language. They take the form of declarations for variables or memory locations in the language syntax. The kinds of operations or procedures used to process data pieces are also determined by data types. The C programming language offers syntax to create array and compound kinds as well as fundamental arithmetic types like integer and real number types. Headers for the C standard library contain definitions of support types that have extra attributes, such as providing storage with a precise size, independent of the language implementation on particular hardware systems. These definitions are to be utilised via include directives. 

Source: Safalta.com


Download these FREE Ebooks:
1. Introduction to Digital Marketing
2. Website Planning and Creation

Main Data Types in C

Every element in C does have a corresponding data type. Each data type has a different set of operations that may be performed on it as well as different memory needs. Let's quickly go through each one:

Free Demo Classes

Register here for Free Demo Classes


Here are some examples of some of the most common data types used in C:
  • Char is the most basic data type in C. It saves a single character and utilises a single byte of memory in almost all compilers.
  • An integer is stored in an int variable, as its name indicates.
  • Floating point numbers with decimal values are stored as only one floats.
  • Double-precision decimal integers are stored inside it (numbers with floating point values).
Additionally, the ranges that various data types may store numbers can vary. These ranges could change depending on the compiler. The list of 32 bit gcc compiler ranges, together with the memory need and format specifiers, are shown below.
 
Data Type 
 
Memory (bytes) 
 
Range 
 
Format Specifier 
 
short int 
 

 
-32,768 to 32,767 
 
%hd 
 
unsigned short int 
 

 
0 to 65,535 
 
%hu 
 
unsigned int 
 

 
0 to 4,294,967,295 
 
%u 
 
int 
 

 
-2,147,483,648 to 2,147,483,647 
 
%d 
 
long int 
 

 
-2,147,483,648 to 2,147,483,647 
 
%ld 
 
unsigned long int 
 

 
0 to 4,294,967,295 
 
%lu 
 
long long int 
 

 
-(2^63) to (2^63)-1 
 
%lld 
 
unsigned long long int 
 

 
0 to 18,446,744,073,709,551,615 
 
%llu 
 
signed char 
 

 
-128 to 127 
 
%c 
 
unsigned char 
 

 
0 to 255 
 
%c 
 
float 
 

 
  %f 
 
double 
 

 
  %lf 
 
long double 
 
16 
 
  %Lf 

For Example:

#include
int main()
{
    int a = 1;
    char b = 'G';
    double c = 3.14;
    printf("Hello World!\n");

    // printing the variables defined
    // above along with their sizes
    printf("Hello! I am a character. My value is %c and "
        "my size is %lu byte.\n",
        b, sizeof(char));
    // can use sizeof(b) above as well

    printf("Hello! I am an integer. My value is %d and "
        "my size is %lu bytes.\n",
        a, sizeof(int));
    // can use sizeof(a) above as well

    printf("Hello! I am a double floating point variable."
        " My value is %lf and my size is %lu bytes.\n",
        c, sizeof(double));
    // can use sizeof(c) above as well

    printf("Bye! Take care. :)\n");

    return 0;
}
 
  Output: 







 

Related Article

RRB ALP Admit Card: 25 नवंबर की एएलपी भर्ती परीक्षा के लिए जारी हुआ प्रवेश पत्र, जानें डाउनलोड करने का तरीका

Read More

CHSE Odisha Class 12 date sheet 2025 out now; Check the exam schedule here

Read More

CBSE Date Sheet 2025: सीबीएसई बोर्ड कक्षा 10वीं 12वीं की डेटशीट हुई जारी, यहां देखें पूरा शेड्यूल

Read More

CBSE Date Sheet 2025: Class 10, 12 timetable at cbse.gov.in awaited, Check the latest update here

Read More

CBSE Board Exam 2025: सीबीएसई बोर्ड 10वीं- 12वीं के लिए जल्द जारी होगी डेटशीट, पिछले साल इस दिन हुई घोषित

Read More

UP Board Exam 2025: यूपी बोर्ड कक्षा 10वीं-12वीं के लिए घोषित हुईं परीक्षा तिथियां, यहां देखें पूरा शेड्यूल

Read More

UP Board Datesheet 2025: Class 10, 12 Exams from 24 February, Check the full schedule here

Read More

UP Board Eams 2025: यूपी बोर्ड परीक्षा की संभावित तिथि जारी, महाकुंभ की वजह से देरी से शुरू होंगे एग्जाम्स

Read More

JEE Advanced 2025: जेईई एडवांस्ड के लिए पात्रता मानदंडों में एक बार फिर हुआ बदलाव, प्रयासों की संख्या घटाई गई

Read More