Write a c program that asks the user to enter integers as inputs to be stored in the variables 'x' & 'y' respectively. There are also two integer pointers named ptrX & ptrY. Assign the values of 'x' and 'y' to ptrX and ptrY respectively, and display them. Sample Input 5 10 Sample Output 5 10 Tag: Pointer c languge

 Write a c program that asks the user to enter integers as inputs to be stored in the variables 'x' & 'y' respectively. There are also two integer pointers named ptrX & ptrY. Assign the values of 'x' and 'y' to ptrX and ptrY respectively, and display them.

Sample Input 5 10 Sample Output 5 10 Tag: Pointer
language



answer:


Here is a C program that asks the user to enter two integers and stores them in the variables x and y. It then declares two integer pointers ptrX and ptrY, and assigns the values of x and y to ptrX and ptrY respectively. Finally, it displays the values of ptrX and ptrY:

#include <stdio.h>

int main(void) { // Declare variables x and y int x, y;

// Prompt the user to enter two integers printf("Enter two integers: "); scanf("%d%d", &x, &y);

// Declare pointers ptrX and ptrY int *ptrX, *ptrY;

// Assign the values of x and y to ptrX and ptrY ptrX = &x; ptrY = &y;

// Display the values of ptrX and ptrY printf("ptrX: %d\n", *ptrX); printf("ptrY: %d\n", *ptrY);

return 0; }

This program will ask the user to enter two integers, and then display the values of ptrX and ptrY, which are pointers to x and y respectively.

For example, if the user enters 5 and 10, the program will output:

ptrX: 5 ptrY: 10

Post a Comment

0 Comments

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();