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

NTET Answer key 2024: एनटीईटी उत्तर कुंजी के खिलाफ इस लिंक से दर्ज कराएं आपत्ति, जानें चुनौती देने का तरीका

Read More

IDBI JAM, AAO Recruitment 2024 Registration begins for JAM/AAO posts, Apply for 600 posts here

Read More

IDBI Bank Recruitment 2024: आईडीबीआई में जेएएम और एएओ के लिए निकली भर्ती, जानें कौन कर सकता है आवेदन

Read More

CAT 2024 Tomorrow: Exam day guidelines, timings, do's and don'ts; Check the list of prohibited items here

Read More

CBSE Single Girl Child Scholarship 2024 Registration window open now, Check the eligibility criteria and more

Read More

UP Police Constable Result 2024: Candidates demand raw scores, question transparency; Check the latest update

Read More

UP Police Result: यूपी पुलिस भर्ती के अभ्यर्थी कर रहे अंक जारी करने की मांग, बोर्ड ने दी प्रतिक्रिया

Read More

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

Read More

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

Read More