Professional Documents
Culture Documents
06 Pointers-All Programs' Listing
06 Pointers-All Programs' Listing
06 Pointers-All Programs' Listing
cpp
#include <stdio.h>
#include <conio.h>
int main()
{
// clrscr();
int x = 50;
int * xptr = &x;
printf("Value of x=%d\n",x);
printf("Address of x=%u\n", &x);
printf("Address of x = %u\n", xptr);
printf("Value of x = %d\n", *xptr);
#include <stdio.h>
#include <conio.h>
int main()
{
int a;
int * c;
int ** d;
// clrscr();
a = 10;
c = &a;
d = &c;
printf("Value of A = %d\n" , a );
printf("Value of A = %d\n" , *c );
printf("Value of A = %d\n" , **d );
printf("Value of A = %d\n" , *(&a) );
printf("Value of C = %u\n" , c );
printf("Address of C = %u\n" , c );
printf("Value of D = %u\n" , d );
printf("Address of D = %u\n" , &d );
getch();
};
Pointer3-c.cpp
#include <stdio.h>
#include <conio.h>
int main()
{
int a,b,c;
void add(int,int,int *);
// clrscr();
a = 10;
b = 20;
add(a,b,&c);
printf("%d + %d = %d\n", a, b, c);
add(50,60,&c);
printf("50 + 60 = %d\n",c);
getch();
}
#include <stdio.h>
#include <conio.h>
int main()
{
int a,b;
void swapv(int,int);
void swapr(int *,int *);
// clrscr();
a = 10;
b = 20;
printf ("Original Values : A = %d\t\t B = %d\n",a,b);
swapv(a,b);
printf ("After swapv : A = %d\t\t B = %d\n",a,b);
swapr(&a,&b);
printf ("After swapr : A = %d\t\t B = %d\n",a,b);
getch();
}