Home / Programs / Write a program to point an integer variable which ever is larger between two variables through a function which returns the address of the larger variable.
Programming Example

Write a program to point an integer variable which ever is larger between two variables through a function which returns the address of the larger variable.

👁 819 Views
💻 Practical Program
📘 Step by Step Learning
Write a program to point an integer variable which ever is larger between two variables through a function which returns the address of the larger variable.

Program Code

#include <stdio.h>
int *pointMax(int *, int *);
int main(void)
{
	int a,b,*p;
	printf("\n a = ?");
	scanf("%d",&a);
	printf("\n b = ?");
	scanf("%d",&b);
	p=pointMax(&a,&b);
	printf("\n*p = %d", *p);
	return 0;
}
int *pointMax(int *x, int *y)
{
	if(*x>*y)
	return x;
	else
	return y;
}

Output


 a = ?12

 b = ?13

*p = 13

Explanation

None

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.