Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Iterative statement



Comment



" ; " after loop



Working with switch case



Test expression




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 int reveres(int n) //function header //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 int r(int n) //function header //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:


© 2018 - All rights reserved