Professional Documents
Culture Documents
Example:
int *ptr;
int Var;
Var=10;
ptr=&Var;
a=38;
p=&a;
a=38;
p=&a;
a=38;
p=&a;
Output:
}
&a=fb6f9c a=38
p=fb6f9c *p=38
a=38;
p=&a;
printf("&a=%x a=%d\n",&a,a);
printf("p=%x *p=%d\n",p,*p);
b=47.5;
q=&b;
printf("&b=%x b=%f\n",&b,b);
printf("q=%x *q=%f\n",q,*q);
}
a=38;
p=&a;
printf("&a=%x a=%d\n",&a,a);
printf("p=%x *p=%d\n",p,*p);
b=47.5;
q=&b; Output:
printf("&b=%x b=%f\n",&b,b); &a=a0e98050 a=38
printf("q=%x *q=%f\n",q,*q); p=a0e98050 *p=38
} &b=a0e98054 b=47.50
q=a0e98054 *q=47.50
Write a program to find area and printf ( "Enter radius of a circle " ) ;
perimeter of a circle using pointers scanf ( "%d", &radius ) ;
int *p;
char *cp;
float *fp;
printf(" size of char =%d\n",sizeof(char));
printf(" size of float =%d\n",sizeof(float));
printf(" size of double =%d\n",sizeof(double));
printf(" size of integer pointer p =%d\n",sizeof(p));
printf(" size of character pointer p =%d\n",sizeof(cp));
printf(" size of floating pointer p =%d\n",sizeof(fp));
return 0;
}
March 29, 2024 CSE, BMSCE 11
Write a c program to test whether a number is
positive, negative ,or equal to zero
1. A pointer variable can be assigned the address of another variable (of the same
datatype).
2. A pointer variable can be assigned the value of another variable (of same
datatype).
3. A pointer variable can be initialized with the null value.
4. Prefix or postfix increment or decrement operators can be applied on a pointer
variable.
5. An integer value can be added or subtracted from a pointer variable.
6. A pointer variable can be compared with another pointer variable of the same
type using relational operators.
7. A pointer variable cannot be multiplied by a constant.
8. A pointer variable cannot be added to another pointer variable.
#include <stdio.h>
int main()
{
int num1, num2, sum;
int *ptr1, *ptr2;
return 0;
}
Example Program
#include <stdio.h>
main() {
int u=20, v=5;
int *p, *q;
p=&u;
q=&v;
Example Program
#include <stdio.h>
main() {
int u=20, v=5;
int *p, *q;
p=&u;
q=&v;
Example Program
#include <stdio.h>
main() {
int u=20, v=5;
int *p, *q;
p=&u;
q=&v;
Output:
printf("%d %d\n", *p+*q, u+v);
25 25
}
Example Program
#include <stdio.h>
main() {
int u=20, v=5;
int *p, *q;
p=&u;
q=&v;
Example Program
#include <stdio.h>
main() {
int u=20, v=5;
int *p, *q;
p=&u;
q=&v;
Output:
printf("%d %d\n", *p+*q, u+v);
25 25
printf(“%d\n”,*p*u);
400
}