Write an interactive program using recursion for the following:
(a) To find the HCF of two given numbers.
(b) To find the GCD of two given numbers.
(c) To find the factorial of a given number.
(a) To find the HCF of two given numbers:
#include <stdio.h>
int hcf(int a, int b) {
if (b == 0) {
return a;
}
return hcf(b, a % b);
}
int main() {
int a, b;
printf("Enter two numbers: ");
scanf("%d%d", &a, &b);
int result = hcf(a, b);
printf("HCF: %d ", result);
return 0;
}
__________ _____ ___ _____ ___.
____ __________ _____ ________ __________.
_____ ______ __________ ___ ______ __________ ____ _______ _________ __________.
______ _______ ____ _________ ___ ________ ________ ______ ________.
_______ __________ ______ ____ ___.
___ _______ ___ ______ _____.
______ ________ _____ ___ ____ __________ ___ _______ _______ ________ ____ _____.
_________ ____ _____ ______ ____ ______ ___ ______ _____ ____.
__________ ________ ___ ______ __________ ___.
_________ ________ _______ ________ _________ ___ _______ _________ _____ ____.
_______ _____ _____ _______ ___ _____.
_________ ________ _________ ___ _____.
____ _________ __________ ______ ___ ____ ___ ________ _____ _______ _________ ________.
________ ___ _______ _________ ________ ___.
________ _________ ___ _____ ____ _____ _______ _______ ______ ____ _______ ____.
___ ______ ___ __________ ________ ______ _______ __________ ________ _______ ______ __________.
______ _____ _________ ____ ____ ____ ______.
__________ ________ ____ ________ _________ _____ ___ ____ _______ _____ ___ _________.
_______ _____ _____ _________ ________.
____ ____ __________ __________ ____ ___ _______ ______.
_______ ___ _____ ____ _______ ______ ______ ___ ___.
________ ________ __________ ___ ____ ____.
____ ____ __________ _________ ______.
- Solved Assignments
- Study Notes
- Guess Papers
- Question Papers
✓ Unlock up to 60% of the answer
✓ No payment required