## Write a C C++ program to find HCF and LCM of two numbers

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

C Language में Token क्या होता है जानने के लिए देखें—Data types in C

C Language में उपलब्ध Operators और इनके विभिन्न प्रकारो को जानने के लिए देखें—Operators in C

### Flowchart to find HCF and LCM of two numbers

### C program to find HCF and LCM of two numbers

```
#include<stdio.h>
int main()
{
int a,b,i=1,hcf,lcm;
printf("Enter two numbers: ");
scanf("%d%d",&a,&b);
while(i<=a&&i<=b)
{
if(a%i==0&&b%i==0)
{
hcf=i;
}
i++;
}
lcm=(a*b)/hcf;
printf("HCF = %d\n",hcf);
printf("LCM = %d\n",lcm);
return 0;
}
```

### C++ program to find HCF and LCM of two numbers

```
#include<iostream>
using namespace std;
int main()
{
int a,b,i=1,hcf,lcm;
cout<<"Enter two numbers: ";
cin>>a>>b;
while(i<=a&&i<=b)
{
if(a%i==0&&b%i==0)
{
hcf=i;
}
i++;
}
lcm=(a*b)/hcf;
cout<<"HCF = "<<hcf<<"\n";
cout<<"LCM = "<<lcm<<"\n";
return 0;
}
```

### Output C C++ program to find HCF and LCM of two numbers

Enter two numbers: 40 60 HCF = 20 LCM = 120

Enter two numbers: 16 24 HCF = 8 LCM = 48

Enter two numbers: 90 60 HCF = 30 LCM = 180

### Programs based on looping in C C++

- Generate series of natural numbers (while, for, do while)
- Generate series of natural numbers and their sum
- Generate series of odd numbers and find their sum
- Generate series of even numbers and find their sum
- Generate table of given number
- Find factorial of given number
- Find power of given number
- Generate multiplication table of given number
- Generating Fibonacci series
- Checking prime number
- Generating series of prime numbers
- Sum of digits of given number
- Reverse of digits of given number
- Checking palindrome number
- Checking Armstrong number
- Generating series of Armstrong numbers
- Convert decimal to binary
- Convert binary to decimal