Tracking the memory consumption using sizeof operator : in C


Here, we have checkedm which type of variables takes how much memory using sizeof operator in C Programming which is the special operator of c Programming Language.
Code goes like this :

/* Program to check the memory consumption of different data types & variables */
#include<stdio.h>
int main()
{
int a;
double b;
char c;
long double d;
float e;
long f;

printf("\n The size of integer variable is : %d \n ",sizeof(a));                // Integer, Short Integer
printf("The size of double type variable is : %d \n ",sizeof(b));          // Double presision floating point
printf("The size of character variable is : %d \n ",sizeof(c));                    // Character
printf("The size of long double variable is : %d \n ",sizeof(d));                // Long Double
printf("The size of floating point variable is : %d \n ",sizeof(e));            // Floating Point
printf("The size of long variable is : %d \n ",sizeof(f));                        // Long Integer
return 0;
}

Output :
----------













I have used Dev CPP to compile this program.
If you are using Turbo C++ IDE, then use conio.h in link section after stdio.h
and use getch(); to hold the output screen, just before the end of main function.
If you have any confusion regarding the program, please, comment below.
Happy Coding !
Thank you
Share on Google Plus

About Nepali Xoro

Interested in Information Technology, Spreading Knowledge for Nepalease IT Students."Loves Traveling", Listen Music and Surfing web.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment