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

Assignment Help:

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


Related Discussions:- C program to demonstrate pointer to variable

Should i call a destructor explicitly on a local variable?, Should I call a...

Should I call a destructor explicitly on a local variable?

Using the substitution model illustrate the process, Each of the following ...

Each of the following two procedures defines a method for adding two positive integers in terms of the procedures inc, which increments its argument by 1, and dec, which decrements

Write a program that finds the minimum total number of she., Write a progra...

Write a program that finds the minimum total number of shelv, C/C++ Programming

Object oriented programming, implementation of the power and factorial in p...

implementation of the power and factorial in programs

Set performance data and print tickets, Create a class  called  ticketSelli...

Create a class  called  ticketSelling that stores booking information of a single performance on a single day and sells the tickets of the performance. The class should include at

Data structure and algorithm, implement two stacks in one array A[1...n] in...

implement two stacks in one array A[1...n] in such a way that neither stack overflows unless the total number of elements in both stacks together is n. For this you need to produce

Compiler design, Compiler Design - Limit In The Method Instructions

Compiler Design - Limit In The Method Instructions

Define the object-oriented terms, Question : (a) Define the following O...

Question : (a) Define the following Object-Oriented terms: (i) Encapsulation (ii) Inheritance (iii) Abstraction (iv) Polymorphism. (b) What are objects in Lingo progra

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd