Home Basic Loop Array string Function Pointer Contact STUDY

# AHF    C    PROGRAM    SOLVING

### Function_ find maximum and minimum of an integer

```
// AHF C PROGRAM SOLVING

//The problem are solving here using FUNCTION

#include<stdio.h>
#include<math.h>
#define pf printf

//function declaration
int r(int);

int reveres(int n);

void main()
{
int x,rev,res;

printf("Enter any integer number: ");
scanf("%d",&x);

//function call
rev=reveres(x);
res=r(x);

printf("\nMaximum digit of the given integer is: %d",rev);

printf("\nMinimum digit of the given integer is: %d",res);

return 0;
}

//definition of the first function

//function body
{
int temp,large=-1;

while(n!=0)
{
temp=n%10;  //separating each digit of the given integer

large=temp>large?temp:large;    //taking large number

n/=10;  //update loop
}

return large;
}

//definition of second function

//function body
{
int temp,min=10;

while(n!=0)
{
temp=n%10;  //separating each digit of the given integer

min=temp<min?temp:min;    //taking large number

n/=10;  //update loop
}

return min;
}

```
OUTPUT: