Write a C Program to find the size of int, float, double, and char.

Prince Patel
By -
0

Write a C Program to find the size of int, float, double, and char.



Here's a C program to find the size of int, float, double, and char:

#include<stdio.h>
#include<conio.h>

void main()
{
    // Find the size of int
    int size_int = sizeof(int);

    // Find the size of float
    int size_float = sizeof(float);

    // Find the size of double
    int size_double = sizeof(double);

    // Find the size of char
    int size_char = sizeof(char);

    // Print the sizes
    printf("Size of int: %d bytes\n", size_int);
    printf("Size of float: %d bytes\n", size_float);
    printf("Size of double: %d bytes\n", size_double);
    printf("Size of char: %d byte\n", size_char);
}


  • sizeof(int), sizeof(float), sizeof(double), and sizeof(char) are used to find the sizes of int, float, double, and char data types, respectively.
  • The sizes are stored in separate variables: size_int, size_float, size_double, and size_char.
  • The printf function is then used to print the sizes of each data type to the console. The format specifiers %d are used for printing integers.
When you run this program, it will display the sizes of int, float, double, and char data types on your system in bytes. Keep in mind that the sizes may vary depending on the system and compiler you are using.

Output:

Please note that in this program may be int size can come 2 bytes because it's depend on compiler.
Tags:

Post a Comment

0Comments

Post a Comment (0)