C program to demonstrate pointer to variable, C/C++ Programming

C program to demonstrate Pointer to variable:

void p2a(int *);

void main()

{

                int x=10, *a,**b;

                int arr[5];

                //pointer to variable

                a=&x;

                b=&a;

                printf("\n\n<<>>\n");

                printf("\nvalue of x=%d",x);

                printf("\nvalue of x using pointer(a) =%d",*a);

                printf("\nvalue of x using pointer to pointer(b) =%d\n",**b);

                printf("\naddress of x=%u",&x);

                printf("\naddress of x=%u",a);

                printf("\naddress of x=%u",*b);

                printf("\naddress of a=%u",&a);

                printf("\naddress of a=%u",b);

                printf("\naddress of b=%u",&b);

 

                //pointer to array

                printf("\n \n\n<<>>\n");

                for (int i=0; i<5; i++)

                {printf("\nEnter %d th element of array\t",i);

                scanf("%d",&arr[i]);

                }

                p2a(&arr[0]);

 

 

}

void p2a(int *y)

{             

                printf("\n printing array element using array\n");

                for (int i=0;i<5;i++)

                {

                                printf("\n %d",*y);

                                y++;

                }

getch();

}

OUT PUT

743_C program to demonstrate Pointer to variable.png

Posted Date: 9/29/2012 7:00:30 AM | Location : United States







Related Discussions:- C program to demonstrate pointer to variable, Assignment Help, Ask Question on C program to demonstrate pointer to variable, Get Answer, Expert's Help, C program to demonstrate pointer to variable Discussions

Write discussion on C program to demonstrate pointer to variable
Your posts are moderated
Related Questions
array of class objects and single inheritance

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

define a class for student


#quGiven the Array class definition in Fig. 11.10-11.11 (pp. 476-479) of the textbook, write a new overloaded operator function for the ‘%’ (modulus) operator (i.e., return an arra

write a c++ program to accept 3 numbers and find the largest of 3 numbers

Need Cron Job Parsing JSON from API, Inserting in to DB Project Description: The Project is to prepare a Cron Job with an adjustable interval in seconds and milli seconds. Cr

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

write c++ program to decode the given code. in mobile keypad the integers from 1 to 9 will display the characters from a to z and 0 will assign a space

Program is to take two arguments and returns the string: Program is to take two arguments and returns the string which is larger the larger string has larger ascii value invok