The below are some special operators of C.
The & operator is used to get the address of the operand or variable. e.g. &x, it will give the address of x.
The * operator is used as a pointer to the variable. e.g. *x, * is a pointer to the variable x.
The sizeof() operator is used to get the size of the variable. e.g. sizeof(x), it will return the size of x.
Here is a C program to demonstrate these operators.
* To demonstrate the & , *, and sizeof() operator
int main ( int argc, char **argv )
long int x = 10;
long int *ptr = &x;
printf ( "Value of x = %d\n ",x );
printf ( "Address of x = %d\n", &x );
printf ( "Address of x = %d\n", ptr );
printf ( "Value of x = %d\n", *ptr );
printf ( "Size of the x = %d ( in Bytes )\n", sizeof ( x ) );
Hope, it would be useful !!
To contribute :
If you like Advance Computing and would like to contribute, you can mail your article to “email@example.com”. You will get credit as your name, email id, designation with the article on this blog.