Let us discuss the following code and determine the outoput.
#include <stdio.h>
int main()
{
int a=10; //normal variable
int *ptr_a; //pointer variable
ptr_a = &a;
int **ptr_ptra; //pointer to pointer
ptr_ptra = &ptr_a;
printf("value of a: %d\n",a);
printf("value of a using pointer: %d\n",*ptr_a);
printf("value of a using pointer to pointer:
%d\n",**ptr_ptra);
return 0;
}
#include<iostream> #include <iomanip> using namespace std; #include <stdio.h> int main() { int a=10; //normal variable int *ptr_a; //pointer variable ptr_a = &a; // ptr_a is pointing to memory location of a // *ptr_a is used to get the value at address a int **ptr_ptra; //pointer to pointer ptr_ptra = &ptr_a; // ptr_ptra points to memory location of ptr_a // *ptr_ptra is used to get the value at address ptr_a // **ptr_ptra is used to get the value at address a printf("value of a: %d\n",a); printf("value of a using pointer: %d\n",*ptr_a); printf("value of a using pointer to pointer: %d\n",**ptr_ptra); return 0; }
value of a: 10 value of a using pointer: 10 value of a using pointer to pointer: 10
Get Answers For Free
Most questions answered within 1 hours.