Write a program to determine the use of pointer.
Input:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include<stdio.h> int main() { int i = 5, *ip; float f = 5.2, *fp; char c = 'H', *cp; ip = &i; fp = &f; cp = &c; printf("%2d %2.1f %c\n \n", *ip, *fp, *cp ); printf("%2d %2.1f %c\n \n", &i, &f, &c); printf("%2d %2.1f %c\n \n", *(&i), *(&f), *(&c)); printf("%2d %2.1f %c \n\n", *(&ip), *(&fp), *(&cp)); return 0; } |
Result:
5 5.2 H 2686748 0.0 H 5 5.2 H 2686748 0.0 H
No comments:
Post a Comment