0% found this document useful (0 votes)
7 views2 pages

Declaration.: When The Above Code Is Compiled and Executed, It Produces Result Something As Follows

This C++ code declares an integer variable and pointer variable, assigns the address of the integer variable to the pointer variable, and demonstrates accessing the value of the integer variable directly and through the pointer. It outputs the value of the integer variable, the address stored in the pointer variable, and the value at the address in the pointer, all of which match since the pointer variable contains the address of the integer variable.

Uploaded by

Peter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Declaration.: When The Above Code Is Compiled and Executed, It Produces Result Something As Follows

This C++ code declares an integer variable and pointer variable, assigns the address of the integer variable to the pointer variable, and demonstrates accessing the value of the integer variable directly and through the pointer. It outputs the value of the integer variable, the address stored in the pointer variable, and the value at the address in the pointer, all of which match since the pointer variable contains the address of the integer variable.

Uploaded by

Peter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

USING POINTER .

C++

#include <iostream>

using namespace std;

int main ()
{
int var = 20; // actual variable
declaration.
int *ip; // pointer variable

ip = &var; // store address of var in


pointer variable

cout << "Value of var variable: ";


cout << var << endl;

// print the address stored in ip pointer


variable
cout << "Address stored in ip variable: ";
cout << ip << endl;

// access the value at the address available


in pointer
cout << "Value of *ip variable: ";
cout << *ip << endl;

return 0;
}

When the above code is compiled and executed, it


produces result something as follows:
Value of var variable: 20
Address stored in ip variable: 0xbfc601ac
Value of *ip variable: 20
USING POINTER .C++

You might also like