outp

My Cart

Write an algorithm to find the HCF (Highest Common Factor) of the two

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.


Posted on : 2023-11-30 22:53:04 | Author : IGNOU Academy | View : 172

Click Here to Order on WhatsApp

Login or SignUp to View Answer / Comment or Ask Question.. Its Free

Word Count : 528

Sure, I'll provide you with an algorithm to find the Highest Common Factor (HCF) of two numbers and then transform that algorithm into both a C program and a Python script.

### Algorithm to Find HCF:

1. Input two numbers, num1 and num2.
2. Set variable smaller as the smaller of the two numbers and larger as the larger number.
3. Initialize a variable hcf to store the highest common factor, initially set it to 1.
4. Iterate from 1 to smaller:
    - Check if both num1 and num2 are divisible by the current number in the loop.
    - If they are, update the hcf to the current number.
5. Return the hcf as the highest common factor.

### C Program:

```c
#include <stdio.h>

// Function to find HCF of two numbers
int findHCF(int num1, int num2) {
    int smaller = (num1 < num2) ? num1 : num2;
    int hcf = 1;

    for (int i = _________ ___ ________ ____ ____ ___________ __ ________ _____________ _________ ______ _________.
__ ____________ __ _______ _________ ____________ ____________ ______ _____________ ____________ ____ ____________ ____.
__________ ___________ ____ ___ __ ____________.
__ _____________ _____________ _________ _________ ____________ _____ ______.
____________ ___________ _______ ____________ _________ ___ ____________ _________ ____ _____ ____________ ____ ___ ____________.
__ ________ ____________ _________ __ ____ ________ _____________ _____________ __________ __ __________ ________.
______ ____ ___________ _____________ ________ ____________.
___________ _____ __ ___ _____ ____ ___________ ______ ___________ __________ ____ _________ _____________ ____________ ____.
___________ ___ ____ _____ _____________ _____________.
__ ________ _____________ ____ ________ _____________.
_____________ ________ _________ ________ ___ __ _________ __ ___________ ____________ __________.
_________ __ __ __ __________ ____ __ __________ ____________ ___.
____ ____ ____________ _____________ __________ ________ __ __ ____ ____ _____ ____________ _____________ __.
______ _________ _____________ ______ ______ __.
__________ ____________ _______ ___ ______ __ _______.
_____ ________ __ __________ _______ ____ __ _____ ___ __.
______ _______ ________ _______ ___ __________ ____ ___________ ______ _______ ___________ _____ ____________ _________ __.
___________ ________ _________ __________ _______ __ _________ ___ _____.
_____________ ____ _____ ___ ______ ____________ _____________ ___________ ______ ___ ________.
_______ __ ________ ____________ ____ __ _________ ____ _____ ____ _______ ________ ____________ _____________.
_________ ________ ___ ____________ ______ __________ ____ ___________ _____________ ___________ _________ ____.
___ ___________ __ _____ _____________ _____ ____ ______ __________ ____________.
______ ______ __ ______ _________ _________.
_______ ___ ___ _________ ___ _____ ____________ __ __ __ __________.
________ ______ _____ _______ _________ _______ __________ _____________ _____________ ___________ ________ _______ ___________.
_______ _____________ ______ _________ ____ __ _____ ______ ___ _____ __ ________ _______ __________.
___ _____________ ____________ ________ ___________ ________ _____________ __________ ___________ __ _____________.
___ _____ ______ ___ __________ ___ __________ __.
_______ _________ __________ ___________ __ ____________ _____ _______ ___________ ______ __________ ____ _______ ___.
______ _________ _____ ____ ____ __________ ____ _______.
__________ ______ __________ __ ___ _________ _____________ ______ _____________ _________.
______ ______ __ ____________ ____________ ___ _____ _________ ________ ________.
___ __________ ____ _________ ___________ ____ ____ _____________ _________ ____________ _____ ___ ______ _____________.
_____________ ____________ __________ _____ __________.
Click Here to Order Full Assignment on WhatsApp








Degree : PG DIPLOMA PROGRAMMES
Course Name : POST GRADUATE DIPLOMA IN COMPUTER APPLICATIONS
Course Code : PGDCA_NEW
Subject Name : Programming in C and PYTHON
Subject Code : MCS 201
Year : 2023



IGNOU MCS 201 Solved Assignment 2023
Click Here to Order on WhatsApp

Call Now
Contact Us
Welcome to IGNOU Academy

Click to Contact Us

Call - 9199852182 Call - 9852900088 myabhasolutions@gmail.com WhatsApp - 9852900088
New to IGNOU Login to Get Every Update