

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Program to find HCF iteratively in C++
In this tutorial, we will be discussing a program to find HCF iteratively.
For this, we will be provided with two numbers. Our task is to calculate the HCF of the given numbers using an iterative function.
Example
#include <bits/stdc++.h> using namespace std; int get_HCF(int a, int b){ while (a != b){ if (a > b) a = a - b; else b = b - a; } return a; } int main(){ int a = 60, b = 96; cout << get_HCF(a, b) << endl; return 0; }
Output
12
- Related Questions & Answers
- 8085 Program to find the HCF of two given bytes
- Program to find GCD or HCF of two numbers in C++
- Java program to find the GCD or HCF of two numbers
- Program to find the HCF of two given bytes in 8085 Microprocessor
- Program to find HCF (Highest Common Factor) of 2 Numbers in C++
- How to Find HCF or GCD using Python?
- C program to find Highest Common Factor (HCF) and Least Common Multiple (LCM)
- Program to find GCD or HCF of two numbers using Middle School Procedure in C++
- Find the other number when LCM and HCF given in C++
- How to run functions iteratively with async await in JavaScript?
- Find HCF of two numbers without using recursion or Euclidean algorithm in C++
- How can Matplotlib be used to create multiple plots iteratively in Python?
- Can we iteratively import python modules inside a for loop?
- Program to find parity in C++
- Program to find covariance in C++
Advertisements