![](https://electro4u.net/assets/storage/uploads/1660374163-sizeof-operator.png)
sizeof operator in c programming
Understanding the sizeof Operator in C Programming
sizeof Operator: sizeof is a unary operator. This operator gives the size of its operand in terms of bytes. The operand can be a variable, constant or any datatype(int, float, char, etc.
Notes
- sizeof operator symbol: sizeof( )
- it is a unary the operator
- sizeof operator will give us the size of constant, variable, or datatype
- sizeof operator will give us the result in the form of a byte
- in sizeof operator, we should not write any expression
- if suppose expressions are present in sizeof operator those expressions are not going to solve
Program 01
#include
void main()
{
char ch='a';
printf("%d %d %d\n",sizeof(char),sizeof(ch),sizeof('a'));
}
output: 1 1 1
Program to understand the sizeof operator
#include
main()
{
int var;
printf("size of int= %d\n",sizeof(int));
printf("size of float=%d\n",sizeof(float));
printf("size of integer constant =%d\n",sizeof(45));
printf("size of var = %d\n",sizeof(var));
}
Output:
size of int=4
size of float = 4
Size of var =4
Size of integer constant=4
Function Data Passing or function data printing
Function Data passing is done from right to left but printing is done from left to right
Program: Prove the data is passed to right to left
#include
int main()
{
int k=35;
printf("%d %d %d\n",k==35,k=50,k>40);
}
Attention: whenever data pass to the compiler first data pass to the compiler from the right side . first pass k>40
after data k=50
after that k==35
at last " %d %d %d"
all %d treated as one sting but printing is reversed manner means first string print then rest
Top Resources
- Learn-C.org
- C Programming at LearnCpp.com
- GeeksforGeeks - C Programming Language
- C Programming on Tutorialspoint
- Codecademy - Learn C
- CProgramming.com
- C Programming Wikibook
- C Programming - Reddit Community
- C Programming Language - Official Documentation
- GitHub - Awesome C
- HackerRank - C Language
- LeetCode - C
Enroll Now:
[ C-Programming From Scratch to Advanced 2023-2024] "Start Supercharging Your Productivity!"
Contact Us:
- For any inquiries, please email us at [[email protected]].
- Follow us on insta [ electro4u_offical_ ] for updates and tips.
Note: If you encounter any issues or specific errors when running this program, please let me know and I'll be happy to help debug them!