mobileNavlogo
headerlogo

Sizeof() operator in C

Blog Author

Tekslate

Published Date

21st September, 2018

Ratings

Views

837

  • Share this blog :

 About sizeof() operator in C Language

size of : -

It is a operator can keyword in ‘c’ language

  • it is a urinary operator which returns size of even argument.
  • size of operator always returns unsigned integer value only and which value is greater than “Zero”

 

void main()

{ int i; char ch; float f; printf("\n size of int %d”, sizeof(i)); printf(“\n size of char: %d ”, sizeof ch); printf(“\n size of float : %d”, size of F); } o/p: size of int : 2 size of char:1 size of float:4   sizeof(int)       7    2 bytes sizeof(signed)  7  2 bytes sizeof(short)  7   2 sizeof(long) 7   4 sizeof(25)  7   2 sizeof(40000u) 7   2 sizeof(655361) 7   4 sizeof(char)  7  1 sizeof(‘A’)  7   2              // sizeof(65) --- >2 char ch; ch=’A’; sizeof(ch) 7 1 size of character or character variable is 1 byte but the size of character constant is 2 bytes, because by default character constant returns integer value. i.e ‘ASCII’  value of a character. So, we will get 2 bytes sizeof(ch)  7   1 sizeof(float) 7 4 sizeof(double) 7 8 sizeof(long double)  -7   10 sizeof(short double) 7   error sizeof(12.8)  7   8 //double sizeof(12.8f)  7  4   //float sizeof(12.8L)  7 10    // long double sizeof(3.0)  7   8 sizeof(3.5)7   8    

void main()

{ int i; i=0; printf(“\nsize1:%d”, size(i)); printf(“\nsize2:%d”, size(i*1 5l)); printf(“\nsize3:%d”, size(i/2.0)); printf(“\nsize4:%d”, size(i/2.0f)); printf(“\nsize5:%d”, size(i=i*15)); printf(“\ni=%d”,i); o/p : size1         :        2       //int Size2    :        4       // int,long 7 long size3     :        8       //int,double 7 double size4     :        4       //int, float   7 float size 5     :        2       //int,int       7  int i=0   in size of operator all expressions can be evaluated except assignment.  

void main()

{ int a; a=10; printf(“\n size of a: %d”, sizeof(++a));     //a=a+1   ignore inclure printf(“/n a=%d”,a); } o/p : size of a:2 a=10  

About Author
Authorlogo
Name

TekSlate

Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills .

Related Blogs

Write For Us