0% found this document useful (0 votes)
459 views

Data Types in C

This document summarizes the primary data types in C programming. It discusses the integer, character, floating-point, double, and void data types. For each data type, it provides the range, size, and format specifier. It also includes short code examples to demonstrate how each data type can be used and printed in C. The document aims to present an overview of the basic primitive data types available in C and their characteristics.

Uploaded by

Debanshu Mohanty
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
459 views

Data Types in C

This document summarizes the primary data types in C programming. It discusses the integer, character, floating-point, double, and void data types. For each data type, it provides the range, size, and format specifier. It also includes short code examples to demonstrate how each data type can be used and printed in C. The document aims to present an overview of the basic primitive data types available in C and their characteristics.

Uploaded by

Debanshu Mohanty
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

PRIMITIVE

DATA TYPES
IN
C PROGRAMMING
_______________________________

PRESENTED BY
DEBANSHU MOHANTY
REDG. NO-220720100082
DATA TYPE:-

• Each variable in C has an associated data type. Each data


type requires different amounts of memory and has some
specific operations which can be performed over it. It
specifies the type of data that the variable can store like
integer, character, floating, double, etc. The data type is a
collection of data with values having fixed values,
meaning as well as its characteristics.
TYPES OF DATA TYPE:-
PRIMITIVE/PRIMARY DATA TYPE

INTEGER DATA TYPE


CHARACTER DATA TYPE
FLOAT DATA TYPE
DOUBLE DATA TYPE
VOID DATA TYPE
Integer Type
• The integer data type in C is used to store the whole numbers
without decimal values. Octal values, hexadecimal values, and
decimal values can be stored in int data type in C. // C program to print Integer data types.
#include <stdio.h>

 
int main()
{
• Range:  -32768 to 32767     // Integer value with positive data.
    int a = 9;
   
• Size: 2 bytes or 4 bytes     // integer value with negative data.
    int b = -9;
   
• Format Specifier: %d     // U or u is Used for Unsigned int in C.
    int c = 89U;
   
    // L or l is used for long int in C.
    long int d = 99998L;

 
    printf("Integer value with positive data: %d\n", a);
    printf("Integer value with negative data: %d\n", b);
    printf("Integer value with an unsigned int data: %u\n", c);
    printf("Integer value with an long int data: %ld", d);

 
    return 0;
}
// C program to print Integer data types.
#include <stdio.h>
Character Types  
int main()
Character data type allows its variable to store only a {

single character. The storage size of the character is 1. It  


    char a = 'a';
is the most basic data type in C. It stores a single     char c;

character and requires a single byte of memory in almost


 
    printf("Value of a: %c\n", a);

all compilers.  
    a++;
•Range: (-128 to 127) or (0 to 255)     printf("Value of a after increment is: %c\n", a);
   
    // c is assigned ASCII values
•Size: 1 byte     // which corresponds to the
    // character 'c'
    // a-->97 b-->98 c-->99
•Format Specifier: %c     // here c will be printed
    c = 99;

 
    printf("Value of c: %c", c);

 
    return 0;
}
Floating-Point Types // C Program to demonstrate use
// of Floating types
In C programming float data type is used to store floating-point #include <stdio.h>

values. Float in C is used to store decimal and exponential  


values. It is used to store decimal numbers (numbers with int main()
{
floating point values) with single precision.
 
•Range: 1.2E-38 to 3.4E+38     float a = 9.0f;
    float b = 2.5f;
•Size: 4 bytes    
      // 2x10^-4
    float c = 2E-4f;
•Format Specifier: %f       printf("%f\n",a);
      printf("%f\n",b);
      printf("%f",c);
         
   
  return 0;
}
Double Types
// C Program to demonstrate
A Double data type in C is used to store decimal numbers (numbers with // use of double data type
#include <stdio.h>
floating point values) with double precision. It is used to define numeric
values which hold numbers with decimal values in C. Double data type is  
int main()
basically a precision sort of data type that is capable of holding 64 bits of {

decimal numbers or floating points. Since double has more precision as  


    double a = 123123123.00;
compared to that float then it is much more obvious that it occupies twice     double b = 12.293123;
    double c = 2312312312.123123;
the memory as occupied by the floating-point type. It can easily
accommodate about 16 to 17 digits after or before a decimal point.
 
    printf("%lf\n", a);

•Range: 1.7E-308 to 1.7E+308  


    printf("%lf\n", b);

•Size: 8 bytes  
    printf("%lf", c);
•Format Specifier: %lf
 
    return 0;
}
Void Data types
The void data type in C is used to specify that no value
// C program to
is present. It does not provide a result value to its demonstrate
caller. It has no values and no operations. It is used to // use of void pointers
#include <stdio.h>
represent nothing. Void is used in multiple ways as   
function return type, function arguments as void, and int main()
{
pointers to void.
    int val = 30;
    void *ptr = &val;
    printf("%d", *(int
*)ptr);
    return 0;
}
THANK YOU

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy