Home -> Menu -> Pointers

Pointers and Variables
#include <iostream.h>
#include <stdlib.h>
int main()
{
int num;
int *ptrnum;
ptrnum = #
num = 642;
//cout using pointer
cout<<*ptrnum<<endl;
//using variable
cout<<num<<endl;
//changing value of variable
num = 476;
//cout with pointer
cout<<*ptrnum<<endl;
//cout with variable
cout<<num<<endl;
//changing value of variable
num = 546;
//cout with pointer
cout<<*ptrnum<<endl;
//cout with variable
cout<<num<<endl;
//changing value of variable
num += 24;
//cout with pointer
cout<<*ptrnum<<endl;
//cout with variable
cout<<num<<endl;
cout<<"Have a nice day! :)"<<endl;
system("PAUSE");
return 0;
} |