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

Free Demo Classes

Register here for Free Demo Classes

Please fill the name
Please enter only 10 digit mobile number
Please select course
Please fill the email
Something went wrong!
Download App & Start Learning
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.

Source: Safalta.com

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. 
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:
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: 







 

Free Demo Classes

Register here for Free Demo Classes

Trending Courses

Professional Certification Programme in Digital Marketing (Batch-6)
Professional Certification Programme in Digital Marketing (Batch-6)

Now at just ₹ 49999 ₹ 9999950% off

Master Certification in Digital Marketing  Programme (Batch-12)
Master Certification in Digital Marketing Programme (Batch-12)

Now at just ₹ 64999 ₹ 12500048% off

Advanced Certification in Digital Marketing Online Programme (Batch-23)
Advanced Certification in Digital Marketing Online Programme (Batch-23)

Now at just ₹ 24999 ₹ 3599931% off

Advance Graphic Designing Course (Batch-9) : 90 Hours of Learning
Advance Graphic Designing Course (Batch-9) : 90 Hours of Learning

Now at just ₹ 19999 ₹ 3599944% off

Flipkart Hot Selling Course in 2024
Flipkart Hot Selling Course in 2024

Now at just ₹ 10000 ₹ 3000067% off

Advanced Certification in Digital Marketing Classroom Programme (Batch-3)
Advanced Certification in Digital Marketing Classroom Programme (Batch-3)

Now at just ₹ 29999 ₹ 9999970% off

Basic Digital Marketing Course (Batch-24): 50 Hours Live+ Recorded Classes!
Basic Digital Marketing Course (Batch-24): 50 Hours Live+ Recorded Classes!

Now at just ₹ 1499 ₹ 999985% off

WhatsApp Business Marketing Course
WhatsApp Business Marketing Course

Now at just ₹ 599 ₹ 159963% off

Advance Excel Course
Advance Excel Course

Now at just ₹ 2499 ₹ 800069% off