Program in c to learn pointer in C,pointer2.cpp
#include<iostream>
using namespace std;
int main()
{
int a=10;
int *ptr1, **ptr2; //note thatptr2 is ptr to ptr
ptr1=&a;
ptr2=&ptr1;
cout<<"Value of a is : \n"<<a<<"\n";
cout<<"Value of a is : \n"<<*ptr1<<"\n";
cout<<"Manipulating the value of contained by pointer \n";
*ptr1=(*ptr1)/2;
cout<<"Value of a is : \n"<<a<<"\n";
cout<<"Value of a is : \n"<<*ptr1<<"\n";
//cout<<"Adress of a is : \n"<<ptr1<<"\n";
//cout<<"Address of ptr1 is: \n"<<ptr2<<"\n";
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int a=10;
int *ptr1, **ptr2; //note thatptr2 is ptr to ptr
ptr1=&a;
ptr2=&ptr1;
cout<<"Value of a is : \n"<<a<<"\n";
cout<<"Value of a is : \n"<<*ptr1<<"\n";
cout<<"Manipulating the value of contained by pointer \n";
*ptr1=(*ptr1)/2;
cout<<"Value of a is : \n"<<a<<"\n";
cout<<"Value of a is : \n"<<*ptr1<<"\n";
//cout<<"Adress of a is : \n"<<ptr1<<"\n";
//cout<<"Address of ptr1 is: \n"<<ptr2<<"\n";
return 0;
}
How to use pointers in C++ cpp C
ReplyDeleteHow to use pointers in C++ cpp C
How to use pointers in C++ cpp C
How to use pointers in C++ cpp C
How to use pointers in C++ cpp C
How to use pointers in C++ cpp C
How to use pointers in C++ cpp C
How to use pointers in C++ cpp C
How to use pointers in C++ cpp C
DeleteHow to use pointers in C++ cpp C
How to use pointers in C++ cpp C
How to use pointers in C++ cpp C
How to use pointers in C++ cpp C
How to use pointers in C++ cpp C
How to use pointers in C++ cpp C
How to use pointers in C++ cpp C
How to use pointers in C++ cpp C
ReplyDeleteHow to use pointers in C++ cpp C
How to use pointers in C++ cpp C
How to use pointers in C++ cpp C