In this program user ask to find out the HCF (highest common factor) using function. As declaring required variable user ask to enter the value. User made a function named “HCF”. Then using control statement if(a>b) the HCF (a,b) else (b,a) after fetching the HCF through getch().
In the next move user calls the function that made HCF. Here user also declare a variable named r=1. And a while condition too. While(r! =0) if the condition got true than the value must be fetch out from use of modulus operator. After that interchange the value within x, y or r. display the result on the screen.
This is C program that asks user to find out the HCF using function.
- Declaring the variable.
- Using control statement.
- Display result on the screen.
This is C program here user need to find out the HCF using function Method. Output of this program shown below.
int hcf(int x,int y);
printf("Enter 2 Numbers : ");
printf("HCF is= %d",d);
int hcf(int x,int y)