Wednesday, June 2, 2021

Size of integer datatype|C PROGRAMMING |R2C TECHNOLOGIES




SIZE OF INTEGER DATATYPE

In this tutorial we are going to see how to do a size of an integer using normal C program.

We are using stdio.h to get the standard input and output of the program.

The size of is a unary operator that returns the size of data (constants, variables, array, structure, etc).

Here we are declaring variables for the integers short , long , long long ,etc….

And now in print statement we are giving a string sizeof the short or integer.

We are declaring %d to declare the sizeof integer in bytes.

We use \n to initiate new line and we are using sizeof to enter the value of the given integer.

#include <stdio.h>     

int main() {

  short a;

  long b;

  long long c;

  short int d;

  unsigned int e;

  long int f;

  long long int g;

  unsigned long int h;

  unsigned long long int i;

  signed char j;

  unsigned char k;

  long double l;

  printf("size of short = %d bytes\n", sizeof(a));

  printf("size of long = %d bytes\n", sizeof(b));

  printf("size of long long = %d bytes\n", sizeof(c));

  printf("size of short int = %d bytes\n", sizeof(d));

  printf("size of unsigned int  = %d bytes\n", sizeof(e));

  printf("size of long int = %d bytes\n", sizeof(f));

  printf("size of long long int = %d bytes\n", sizeof(g));

  printf("size of unsigned long int  = %d bytes\n", sizeof(h));

  printf("size of unsigned long long int = %d bytes\n", sizeof(i));

  printf("size of signed char = %d bytes\n", sizeof(j));

  printf("size of unsigned char = %d bytes\n", sizeof(k));

  printf("size of long double = %d bytes\n", sizeof(l));

Try it out for yourself to learn more!!!

OUTPUT:

  




   


USD TO INR C++ PROGRAMMING

  NALLAMUTHU GOUNDER MAHALINGAM COLLEGE                                                 POLLACHI-642001                                     ...