Miscellaneous Operators in C
November 4, 2020
Besides the others operators as described in the previous several tutorials, there are some few others important operators in C programming language. i,e. sizeof, &, *, ? :.
Now, let’s see the operators in C programming language:
| Operator | Description | Example |
|---|---|---|
| sizeof() | Returns the size of a variable. | sizeof(a), where a is integer, will return 4. |
| & | Returns the address of a variable. | &i; returns the actual address of the variable. |
| * | Pointer to a variable. | *i; indicate a pointer variable i. |
| ? : | Conditional expression. | i==1?”Y”:”N”; If condition is true then value Y otherwise value N. |
C program code with misc operators:
#include<studio.h>
void main()
{
int i = 5;
int *ptr;
ptr=&i;
printf("Address of i is %d.\n", &i);
printf("Value of i is %d.\n", i);
printf("Address of ptr is %d.\n", ptr);
printf("Value of *ptr is %d.\n", *ptr);
}
Output:
Address of i is 6422036. Value of i is 5. Address of ptr is 6422036. Value of *ptr is 5.
Click Operators in C to know other operators in C programming language.
In this tutorial, I have shown misc operators in C. Hope you have enjoyed the tutorial. If you want to get updated, like my facebook page http://www.facebook.com/freetechtrainer and stay connected.