Question

Write an algorithm to find the HCF (Highest Common Factor) of the two numbers entered by a user. Transform your algorithm into a C program, support your program with suitable comments.

05 Mar 2024
Answer :
Word Count : 564

### Algorithm to Find the Highest Common Factor (HCF) of Two Numbers:

1. Input two numbers from the user:
   - Prompt the user to enter two integers.
   
2. Initialize variables:
   - Initialize two variables `num1` and `num2` to store the entered numbers.
   - Initialize a variable `hcf` to store the highest common factor.
   
3. Find the smaller number:
   - Compare `num1` and `num2` to find the smaller number and store it in a variable `smaller`.
   
4. Iterate from 1 to the smaller number:
   - Start a loop from 1 to the `smaller` number.
   
___ ______ _________ ____ ________ _________ _____.
______ _____ _______ ___ ________ ________.
_________ _________ _______ ____ _______ _____ ________ _________ ___ ____ __________ _________.
__________ _________ __________ __________ ___ ______ ____ __________.
______ _________ ___ _________ ___ _______ _______.
_______ ______ _________ __________ _______ ____.
___ __________ _____ ________ ______ ________ __________ ___ _______ ___.
______ ____ _____ __________ __________ ________ _________ _____ ___ ___ ______.
______ ________ _________ ________ ________ __________ ______ ___ ____ ____ _____.
________ ____ ________ __________ ______ _________ _______ ______ ________ ________ __________ ______.
_______ ______ _______ ____ ____ _______ _______ ____ ____ __________.
_______ _________ ________ ____ _________ _____ _________ ________.
______ ________ ____ ______ ___.
________ ____ _______ _____ ___ __________ ________ _____ ________.
_____ ________ _________ ______ _______ ____.
______ _____ _______ __________ ___ ___ __________ ____.
_____ ________ _____ ___ ____ __________.
_______ ____ __________ ________ ________ __________ ____ _____ ______ _______.
_____ _________ _________ ______ ___ _____ _________ _______ _____ _____ _________.
___ ______ _______ _________ __________.
__________ __________ _______ _______ _________ ______ ________ ___ _______ _____.
___ ________ ___ _________ _______ _______ _________ ____ ______ ____ __________.
______ _____ _________ _______ ________ __________ __________ _____ _________ ____.
_______ _______ ___ ___ __________ _______ __________ _________.
_______ ___ ________ ______ ______ _________ _______.
____ _____ _______ ______ ____ ____.
__________ ____ __________ _________ _____ _______ ___ _______ ________ ____ ______.
__________ _______ _________ ______ ______ __________ ____.
_______ ________ __________ _______ __________ _________ ______ ________ ______ ____ ______.
____ _____ _____ _____ _____ ___ ___ ___ _________ ________.
____ _________ ________ ________ ____ _____ __________ __________ _____ ____ _____.
_____ __________ ___ ___ ______ ______ _____ ________ _____ _______.
_____ _______ _________ _________ ___ __________.
_______ ___ ___ __________ ___ __________ _____ ________ ______.
__________ _____ _______ _____ __________ __________ _____ ______ ________.
_______ _____ ______ _________ ___ ___ _____ ______ _________ ___ _______ ________.
________ __________ __________ ________ ________ ______ ___.
_______ __________ _________ _____ ____ ________ ________ ___ _______ ____ _____.
_______ _______ _______ _____ ___ ________.
____ ______ ____ ______ ________ _________ _____ _________ _____ _____.
_______ __________ _____ __________ ________.
______ _________ _______ __________ _____ ___ ____.
__________ _____ ______ ___ _______ ______ ______ _________ ______.
_____ _____ ___ ______ ___ _______ _________ ___.
_________ ________ ____ ______ _____ ______ _____ __________.
_______ ___ ________ ________ ____ _____ ______ ______.
______ ______ ___ __________ _________ __________ _______.
________ _______ _________ ________ ____ ___ ____ ___ ________ ______ ______.
____ ______ _____ ______ ______ ________ __________ ________ _______.
_______ ______ _________ _____ ________ _________ _______ _____.
___ ______ _____ ____ __________ _____ _______ ________ _________ _____.
_____ _________ _____ ___ ______ ___.

IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
'; fetch( "query.php?type=1&method=0&lr=0&app=401&mycartproduct=1", { method: "GET", cache: "no-store" } ) .then(function(response) { if (!response.ok) { throw new Error( "HTTP " + response.status ); } return response.text(); }) .then(function(html) { loader.innerHTML = html; /* Your existing function, if available. */ if (typeof updateTotals === "function") { updateTotals(); } else { calculateCartTotal(); } }) .catch(function(error) { console.error( "Cart loading error:", error ); loader.innerHTML = '
Unable to load cart.
'; });}/* ========================================================= CALCULATE TOTAL========================================================= */function calculateCartTotal() { let subtotal = 0; /* Looks for .item-price inside AJAX products. Examples accepted: ₹200 ₹200.00 Rs 200 Rs. 200 200 200.00 */ const prices = document.querySelectorAll( '#loadmycart .item-price' ); prices.forEach(function(element) { let text = element.textContent || ''; text = text .replace(/₹/g, '') .replace(/Rs\.?/gi, '') .replace(/,/g, '') .trim(); let value = parseFloat(text); if (!isNaN(value)) { subtotal += value; } }); updateCartDisplay(subtotal);}/* ========================================================= UPDATE TOTAL DISPLAY========================================================= */function updateCartDisplay(total) { const subtotalElement = document.getElementById('subtotal'); const totalElement = document.getElementById('total'); const checkoutButton = document.getElementById('checkoutButton'); const noItems = document.getElementById('noitems'); const amount = Number(total) || 0; if (subtotalElement) { subtotalElement.textContent = '₹' + amount.toFixed(2); } if (totalElement) { totalElement.textContent = '₹' + amount.toFixed(2); } /* EMPTY CART */ if (amount
Top