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.

C Programming Language Pointer in C Language (Article) Pointer in C Language (Program)

724

Program:

#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

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.