#### C Programming

- Print integer
- Add & subtract
- Odd & even
- Multiply & divide
- Check vowels
- Letter grade program
- Leap year program
- Sum of digits
- Prime numbers
- Sum of numbers
- Find factorial
- Fibonacci series
- Fibonacci triangle
- Number triangle
- Alphabet triangle
- Armstrong numbers
- Palindrome numbers
- Swap number
- Reverse number
- Decimal to binary
- Assembly code in C
- Matrix multiplication
- HCF & LCM
- nCr & nPr
- Print pattern
- Floyd’s triangle
- Pascal triangle
- Count digits
- Strong numbers
- Perfect numbers
- Sum of natural number
- Binary to decimal
- Decimal to octal
- Octal to decimal
- Binary to octal
- Octal to binary
- Add using pointer
- Bubble sort
- Insertion sort
- Selection sort
- Quick sort
- Binary search
- Linear search
- Largest element of array
- Smallest element of array
- Reverse Array
- Variable size & limit
- ASCII value of character
- Sum of array elements
- Number of element in array
- Merge two array
- Insert element in array
- Delete element from array
- Add two matrix
- Transpose matrix
- Print string
- Reverse string
- Delete vowels
- Sort string
- Remove spaces
- Swap string
- Random numbers
- Print date & time
- Print IP address
- Shut down computer

## Find highest common factor and least common multiple using C

Now, let’s see some program to find highest common factor and least common multiple in C.

## C program to find highest common factor and least common multiple (HCF and LCM)

```
// C program to find greatest common factor and least common multiple
#include <stdio.h>
int main(){
int x, y, fNum, sNum, p, hcf, lcm;
printf("Enter first integer : ");
scanf("%d", &fNum);
printf("Enter second integer : ");
scanf("%d", &sNum);
x = fNum;
y = sNum;
while (y != 0){
p = y;
y = x % y;
x = p;
}
hcf = x;
lcm = (fNum*sNum)/hcf;
printf("\nGreatest common factor of %d and %d is = %d\n", fNum, sNum, hcf);
printf("Least common multiple of %d and %d is = %d\n", fNum, sNum, lcm);
return 0;
}
```

### HCF & LCF program output:

## C program to find GCD and LCM using function

```
// C program to find greatest common divisor and least common multiple using function
#include <stdio.h>
long gcdFunction(long i, long j){ // Function definition
if (i == 0){
return j;
}
while (j != 0){
if (i > j){
i = i - j;
}else{
j = j - i;
}
}
return i;
}
int main(){
long a, b, hcf, lcm;
printf("Enter first integer here : ");
scanf("%ld", &a);
printf("Enter second integer here : ");
scanf("%ld", &b);
hcf = gcdFunction(a, b);
lcm = (a * b) / hcf;
printf("\nGCD of %ld and %ld is = %ld\n", a, b, hcf);
printf("LCM of %ld and %ld = %ld\n", a, b, lcm);
return 0;
}
```

### Output of GCD & LCF program

**Previous page**:Â **Matrix multiplication**

**Next page**:Â **nCr and nPr in C**