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

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

HCF and LCM of two numbers flowchart

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++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of odd numbers and find their sum
  4. Generate series of even numbers and find their sum
  5. Generate table of given number
  6. Find factorial of given number
  7. Find power of given number
  8. Generate multiplication table of given number
  9. Generating Fibonacci series
  10. Checking prime number
  11. Generating series of prime numbers
  12. Sum of digits of given number
  13. Reverse of digits of given number
  14. Checking palindrome number
  15. Checking Armstrong number
  16. Generating series of Armstrong numbers
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to:

Write a C C++ program to generate multiplication table

Write a C C++ program to generate multiplication table

If statement और decision making statements के बारे में अधिक जानने के लिए देखें— If statements in C

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

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

Flowchart to generate multiplication table

Multiplication table of given number flowchart

C program to generate multiplication table

#include<stdio.h>
int main()
{
    int num,c=1,res;
    printf("Enter a number: ");
    scanf("%d",&num);
    while(c<=10)
    {
        res=num*c;
        printf("%d*%d=%d\n",num,c,res);
        c++;
    }
    return 0;
}

C++ program to generate multiplication table

#include<iostream>
using namespace std;
int main()
{
    int num,c=1,res;
    cout<<"Enter a number: ";
    cin>>num;
    while(c<=10)
    {
        res=num*c;
        cout<<num<<"*"<<c<<"="<<res<<"\n";
        c++;
    }
    return 0;
}

Output of C C++ program to generate multiplication table

Enter a number: 5
5*1=5
5*2=10  
5*3=15  
5*4=20  
5*5=25  
5*6=30  
5*7=35  
5*8=40  
5*9=55  
5*10=50 
Enter a number: 5
12*1=12
12*2=24  
12*3=36  
12*4=48  
12*5=60  
12*6=72  
12*7=84  
12*8=96  
12*9=108  
12*10=120  

Important iteration logic programs in C C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of odd numbers and find their sum
  4. Generate series of even numbers and find their sum
  5. Generate table of given number
  6. Find factorial of given number
  7. Find power of given number
  8. HCF and LCM of two numbers
  9. Generating Fibonacci series
  10. Checking prime number
  11. Generating series of prime numbers
  12. Sum of digits of given number
  13. Reverse of digits of given number
  14. Checking palindrome number
  15. Checking Armstrong number
  16. Generating series of Armstrong numbers
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to:

Write a C C++ program to find power of given number

Write a C C++ program to find power of given number

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

C Language की विशेषताओं एवं शक्तियों को जानने के लिए देखें—Features and Powers of C

Flowchart to find power of given number

Power of given number flowchart

C program to find power of given number

#include<stdio.h>
int main()
{
    int num,pow,c=1,res=1;
    printf("Enter number: ");
    scanf("%d",&num);
    printf("Enter power : ");
    scanf("%d",&pow);
    while(c<=pow)
    {
        res=res*num;
        c++;
    }
    printf("Result = %d",res);
    return 0;
}

C++ program to find power of given number

#include<iostream>
using namespace std;
int main()
{
    int num,pow,c=1,res=1;
    cout<<"Enter number: ";
    cin>>num;
    cout<<"Enter power : ";
    cin>>pow;
    while(c<=pow)
    {
        res=res*num;
        c++;
    }
    cout<<"Result = "<<res;
    return 0;
}

Output of C C++ program to find power of given number

Enter number: 5
Enter power : 3
Result = 125
Enter number: 3
Enter power : 4
Result = 81 
Enter number: 2
Enter power : 5
Result = 32 

Similar programs in C C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of odd numbers and find their sum
  4. Generate series of even numbers and find their sum
  5. Generate table of given number
  6. Find factorial of given number
  7. Generate multiplication table of given number
  8. HCF and LCM of two numbers
  9. Generating Fibonacci series
  10. Checking prime number
  11. Generating series of prime numbers
  12. Sum of digits of given number
  13. Reverse of digits of given number
  14. Checking palindrome number
  15. Checking Armstrong number
  16. Generating series of Armstrong numbers
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to:

Write a C C++ program to find factorial of given number

Write a C C++ program to find factorial of given number

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

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

Unconditional branching statements के बारे में अधिक जानकारी के लिए देखें— Break, Continue and Goto in C

Flowchart to find factorial of given number

Factorial of given number flowchart

C program to find factorial of given number

#include<stdio.h>
int main()
{
    int num,c=1,res=1;
    printf("Enter a number: ");
    scanf("%d",&num);
    while(c<=num)
    {
        res=res*c;
        c++;
    }
    printf("Factorial = %d",res);
    return 0;
}

C++ program to find factorial of given number

#include<iostream>
using namespace std;
int main()
{
    int num,c=1,res=1;
    cout<<"Enter a number: ";
    cin>>num;
    while(c<=num)
    {
        res=res*c;
        c++;
    }
    cout<<"Factorial = "<<res;
    return 0;
}

Output of C C++ program to find factorial of given number

Enter a number: 3
Factorial = 6
Enter a number: 4
Factorial = 24
Enter a number: 5
Factorial = 120 

Related programs in C C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of odd numbers and find their sum
  4. Generate series of even numbers and find their sum
  5. Generate table of given number
  6. Find power of given number
  7. Generate multiplication table of given number
  8. HCF and LCM of two numbers
  9. Generating Fibonacci series
  10. Checking prime number
  11. Generating series of prime numbers
  12. Sum of digits of given number
  13. Reverse of digits of given number
  14. Checking palindrome number
  15. Checking Armstrong number
  16. Generating series of Armstrong numbers
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to:

Write a C C++ program to generate table of given number

Write a C C++ program to generate table of given number

C Language के बारे में अधिक जानने के लिए देखें—Brief Introduction of C

C++ Language के बारे में अधिक जानने के लिए देखें—Brief Introduction of C++

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

Flowchart to generate table of given number

Table of given number flowchart

C program to generate table of given number

#include<stdio.h>
int main()
{
    int num,c=1,res;
    printf("Enter a number: ");
    scanf("%d",&num);
    while(c<=10)
    {
        res=num*c;
        printf("%d\n",res);
        c++;
    }
    return 0;
}

C++ program to generate table of given number

#include<iostream>
using namespace std;
int main()
{
    int num,c=1,res;
    cout<<"Enter a number: ";
    cin>>num;
    while(c<=10)
    {
        res=num*c;
        cout<<res<<"\n";
        c++;
    }
    return 0;
}

Output of C C++ program to generate table of given number

Enter a number: 5
5
10
15
20
25
30
35
40
45
50
Enter a number: 12
12
25
36
48
60
72
84
96
108
120

Important looping programs in C C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of odd numbers and find their sum
  4. Generate series of even numbers and find their sum
  5. Find factorial of given number
  6. Find power of given number
  7. Generate multiplication table of given number
  8. HCF and LCM of two numbers
  9. Generating Fibonacci series
  10. Checking prime number
  11. Generating series of prime numbers
  12. Sum of digits of given number
  13. Reverse of digits of given number
  14. Checking palindrome number
  15. Checking Armstrong number
  16. Generating series of Armstrong numbers
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to:

C C++ program to generate series of even numbers and find sum

C C++ program to generate series of even numbers and find sum

C Language के बारे में अधिक जानने के लिए देखें—Brief Introduction of C

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

Flowchart to generate series of even numbers and find sum

Generate series of even numbers and their sum flowchart

C program to generate series of even numbers and find sum

#include<stdio.h>
int main()
{
    int num=2,n,sum=0;
    printf("Enter n: ");
    scanf("%d",&n);
    while(num<=n)
    {
        printf("%d\n",num);
        sum=sum+num;
        num=num+2;
    }
    printf("Sum of series = %d",sum);
    return 0;
}

C++ program to generate series of even numbers and find sum

#include<iostream>
using namespace std;
int main()
{
    int num=2,n,sum=0;
    cout<<"Enter n: ";
    cin>>n;
    while(num<=n)
    {
        cout<<num<<"\n";
        sum=sum+num;
        num=num+2;
    }
    cout<<"Sum of series = "<<sum;
    return 0;
}

Output of C C++ program to generate series of even numbers and find sum

Enter n: 10
2
4
6
8
10
Sum of series: 30
Enter n: 10
2
4
6
8
10
12
14
16
18
20
Sum of series: 110

Important programs using loops in C C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of odd numbers and find their sum
  4. Generate table of given number
  5. Find factorial of given number
  6. Find power of given number
  7. Generate multiplication table of given number
  8. HCF and LCM of two numbers
  9. Generating Fibonacci series
  10. Checking prime number
  11. Generating series of prime numbers
  12. Sum of digits of given number
  13. Reverse of digits of given number
  14. Checking palindrome number
  15. Checking Armstrong number
  16. Generating series of Armstrong numbers
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to:

C C++ program to generate series of odd numbers and find sum

C C++ program to generate series of odd numbers and find sum

Flowchart to generate series of odd numbers and find sum

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

If statement और decision making statements के बारे में अधिक जानने के लिए देखें— If statements in C

Generate series of odd numbers and their sum flowchart

C program to generate series of odd numbers and find sum

#include<stdio.h>
int main()
{
    int num=1,n,sum=0;
    printf("Enter n: ");
    scanf("%d",&n);
    while(num<=n)
    {
        printf("%d\n",num);
        sum=sum+num;
        num=num+2;
    }
    printf("Sum of series = %d",sum);
    return 0;
}

C++ program to generate series of odd numbers and find sum

#include<iostream>
using namespace std;
int main()
{
    int num=1,n,sum=0;
    cout<<"Enter n: ";
    cin>>n;
    while(num<=n)
    {
        cout<<num<<"\n";
        sum=sum+num;
        num=num+2;
    }
    cout<<"Sum of series = "<<sum;
    return 0;
}

Output of C C++ program to generate series of odd numbers and find sum

Enter n: 10
1
3
5
7
9
Sum of series = 25
Enter n: 20
1
3
5
7
9
11
13
15
17
19
Sum of series = 100

Similar repetitive logic programs in C C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of even numbers and find their sum
  4. Generate table of given number
  5. Find factorial of given number
  6. Find power of given number
  7. Generate multiplication table of given number
  8. HCF and LCM of two numbers
  9. Generating Fibonacci series
  10. Checking prime number
  11. Generating series of prime numbers
  12. Sum of digits of given number
  13. Reverse of digits of given number
  14. Checking palindrome number
  15. Checking Armstrong number
  16. Generating series of Armstrong numbers
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to:

C C++ program to generate series of natural numbers and find sum

C C++ program to generate series of natural numbers and find sum

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

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

Flowchart program to generate series of natural numbers and find sum

Generate series of natural numbers and their sum flowchart

C program to generate series of natural numbers and find sum

#include<stdio.h>
int main()
{
    int num=1,n,sum=0;
    printf("Enter n: ");
    scanf("%d",&n);
    while(num<=n)
    {
        printf("%d\n",num);
        sum=sum+num;
        num++;
    }
    printf("Sum of series = %d",sum);
    return 0;
}

C++ program to generate series of natural numbers and find sum

#include<iostream>
using namespace std;
int main()
{
    int num=1,n,sum=0;
    cout<<"Enter n: ";
    cin>>n;
    while(num<=n)
    {
        cout<<num<<"\n";
        sum=sum+num;
        num++;
    }
    cout<<"Sum of series = "<<sum;
    return 0;
}

Output of C C++ program to generate series of natural numbers and find sum

Enter n: 5
1
2
3
4
5
Sum of series = 15
Enter n: 10
1
2
3
4
5
6
7
8
9
10
Sum of series = 55 

Other Iterative logic programs in C C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of odd numbers and find their sum
  3. Generate series of even numbers and find their sum
  4. Generate table of given number
  5. Find factorial of given number
  6. Find power of given number
  7. Generate multiplication table of given number
  8. HCF and LCM of two numbers
  9. Generating Fibonacci series
  10. Checking prime number
  11. Generating series of prime numbers
  12. Sum of digits of given number
  13. Reverse of digits of given number
  14. Checking palindrome number
  15. Checking Armstrong number
  16. Generating series of Armstrong numbers
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to:

Write a C C++ program to generate series of natural numbers

Write a C C++ program to generate series of natural numbers

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

Unconditional branching statements के बारे में अधिक जानकारी के लिए देखें— Break, Continue and Goto in C

Flowchart to generate series of natural numbers

Generate series of natural numbers flowchart

C program to generate series of natural numbers using while loop

#include<stdio.h>
int main()
{
    int num=1;
    while(num<=5)
    {
        printf("%d\n",num);
        num++;
    }
    return 0;
}

C program to generate series of natural numbers using for loop

#include<stdio.h>
int main()
{
    int num;
    for(num=1; num<=5; num++)
    {
        printf("%d\n",num);
    }
    return 0;
}

C program to generate series of natural numbers using do while loop

#include<stdio.h>
int main()
{
    int num=1;
    do
    {
        printf("%d\n",num);
        num++;
    }while(num<=5);
    return 0;
}

C++ program to generate series of natural numbers using while loop

#include<iostream>
using namespace std;
int main()
{
    int num=1;
    while(num<=5)
    {
        cout<<num<<"\n";
        num++;
    }
    return 0;
}

C++ program to generate series of natural numbers using for loop

#include<iostream>
using namespace std;
int main()
{
    int num;
    for(num=1; num<=5; num++)
    {
        cout<<num<<"\n";
    }
    return 0;
}

C++ program to generate series of natural numbers using do while loop

#include<iostream>
using namespace std;
int main()
{
    int num=1;
    do
    {
        cout<<num<<"\n";
        num++;
    }while(num<=5);
    return 0;
}

Output of C C++ program to generate series of natural numbers using while, for and do while loops

1
2
3
4
5

Other looping programs in C C++

  1. Generate series of natural numbers and their sum
  2. Generate series of odd numbers and find their sum
  3. Generate series of even numbers and find their sum
  4. Generate table of given number
  5. Find factorial of given number
  6. Find power of given number
  7. Generate multiplication table of given number
  8. HCF and LCM of two numbers
  9. Generating Fibonacci series
  10. Checking prime number
  11. Generating series of prime numbers
  12. Sum of digits of given number
  13. Reverse of digits of given number
  14. Checking palindrome number
  15. Checking Armstrong number
  16. Generating series of Armstrong numbers
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to: