Go to your University || Python Lab || DSA Lab || AI & Machine Learning Lab || Linux Lab || OOPs Lab || DBMS Lab || JAVA Lab ||| Free Online Tutorials ||| 
companies for Campus Placement || Logical Reasoning || Quantitative Aptitude || General English || Technical-MCQ and Interview Questions || HR Interview Questions

1 Answer

0 like 0 dislike
by Goeduhub's Expert (7.8k points)
 
Best answer

With a type as operand

Evaluates into the size in bytes, of type size_t, of objects of the given type. Requires parentheses around the type.

printf("%zu\n", sizeof(int)); /* Valid, outputs the size of an int object, which is platformdependent. */ 

printf("%zu\n", sizeof int); /* Invalid, types as arguments need to be surrounded by parentheses! */

With an expression as operand

Evaluates into the size in bytes, of type size_t, of objects of the type of the given expression. The expression itself is not evaluated. Parentheses are not required; however, because the given expression must be unary, it's considered best practice to always use them.

char ch = 'a'; 

printf("%zu\n", sizeof(ch)); /* Valid, will output the size of a char object, which is always 1 for all platforms. */ 

printf("%zu\n", sizeof ch);  /* Valid, will output the size of a char object, which is always 1 for all platforms. */ 

Related questions

0 like 0 dislike
1 answer 4 views
0 like 0 dislike
1 answer 7 views
0 like 0 dislike
1 answer 8 views
0 like 0 dislike
1 answer 7 views
  Realize your learning potential with courses starting at ₹ 420
 Placements:   List of companies | Logical Reasoning Questions | Quantitative Aptitude Questions | General English Questions | Technical-MCQ and Interview Questions
 Online Free Training:  MACHINE LEARNINGPython Programming | Database Management System(DBMS) | Object Oriented Programming(OOPs) using C++ | Data Structures and Algorithms(DSA) | Java Programming | Linux/Unix | C Programming
Exams: List of Exams After Graduation | List of Engineering Entrance Examinations (UG/PG) | JEE Main | JEE Advanced | GATE | IES | ISROList of PSUs
 Download Previous Year Papers For:  GATE | IES | RAJASTHAN TECHNICAL UNIVERSITY (RTU-Kota)RPSC Technical Exams | ISRO
 Goeduhub
About Us | Contact Us   Social::   |  | 
...