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

C program to demonstrate Pointer to array:

void p2a(int *);

void main()

{

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

                int arr[5];

                a=&x;//pointer to variable

                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();

}

 

Posted Date: 9/29/2012 7:06:44 AM | Location : United States







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

Write discussion on C program to demonstrate pointer to array
Your posts are moderated
Related Questions
Problem : Compiler Design - Limit the methods Rahul is a newbie to the programming and while learning the programming language he came to know the following rules: ·


Hello, Do you have any idea for programming project to simulate a network attack (threat) mechanism or a defense mechanism. Can I get some suggestions for this. Please include th

Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given

Define Array of Structures? An Array of Structures is an assortment of the same data types which are declared as structures. It is useful to store large and different number of

hwat is the area fsdjlakl;aeklfjtealrtl;gka

There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides. But he sometimes mistakes doing tha

Write a program called Series that will print/display a series of numbers starting with 1 and ending with the last number that is less than 30. The series should include only odd n

A: you can exploit by overloading standard operators on a class, the intuition of the users of that class. This allow users program in the language of the problem domain instead of

Pointer Arithmetic We can manipulate the pointers too. We can perform operations such as addition, subtraction, increment and decrement etc.,. As the pointer variables have add