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
payment system, in c++ only..just use the printf or scanf.please

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

Write a function that calculates the number of elapsed days between two dates. For example the days between Feb 3, 1970 and June 21, 1980? Becareful for the Leap year

A r r a y s w i t h i n a c l a s s: I t i s j u s t d ecl a r i n g o r c on s t ru c ti n g a d e r i v e d t

What is Structure? An Array is a data structure whose elements are all of the similar data type. The structure is a data structure whose individual elements are able to differ


Is it possible to create your own header files? - Yes, it's possible to create a customized header file. - To do this, you just need to include function prototypes that you

Write a program to calculate the average of ten numbers       #include stdio.h     /* Only this header is needed since only IO are used */     void main()     {          char

Write a program to sort an array of strings. Use new and delete operators. Write a program to find the factorial of a number using recursion. If we do not accept the number

Need assignment help What's the order that local objects are destructed?