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 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;
}


                        

🖥 Program Output


 a = ?12

 b = ?13

*p = 13

                            

📘 Explanation

None
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.