- 2067 Asar · 4 marks
Meaning of & and * in C
Short answer
& is a unary address-of operator (e.g., &x gives address) and a binary bitwise AND. * indicates a pointer in declarations (int *p), is a unary dereference operator (accessing value at address), and a binary multiplication operator.
What are the significant meanings of '&' and '*' established in C programming?
Meaning of &
- Address-of operator (unary):
&xgives the memory address ofx. Example:p = &x;andscanf("%d", &x);. - Bitwise AND (binary):
a & bANDs each bit, e.g. 5 & 3 = 1. - (
&&is the separate logical AND.)
Meaning of *
- Pointer declaration: in
int *p;the star sayspis a pointer. - Indirection (dereference) operator (unary):
*pgives the value stored at the address held byp. - Multiplication (binary):
a * b.
#include <stdio.h>
int main(void)
{
int a = 5, b = 3, c;
int *p = &a; /* & : address of; * in declaration: pointer */
c = *p * b; /* * : value at address (dereference), then multiply */
printf("%d %d %d\n", c, a & b, a * b);
return 0;
}
Output: 15 1 15 (c = *p × b = 5 × 3 = 15, then a & b = 1, then a × b = 15).
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Function prototyping · Computer Programming, chapter 6
- FT of DC; meaning of ESD and PSD · Signals and Systems, chapter 3