n2 : -n2; while(n1!=n2) { if(n1 > n2) n1 -= n2; else n2 -= n1; } printf("GCD = %d",n1); return 0; } Output Enter two integers: 81 -153 GCD = 9 You can also use recursion to find the GCD.Share on: Did you find
In the end, the value of n1 is the GCD or HCF of the given two numbers. Execution Steps No.Recursive calln1n2n1 % n2 1 hcf(366, 60) 366 60 6 2 hcf(60, 6) 60 6 0 Final hcf(6, 0) 6 0 - Here's the equivalent Java code: Java Program to Find G.C.D. using recursion...
C program to find the largest of three numbers using Pointers C program to count vowels and consonants in a String using pointer C program to print String using Pointer C program to swap two numbers using pointers C program to create initialize and access a pointer variable C Program to acces...
gcd.c updated gcd.c file with better functionality getPIDs.c added a program to get all PIDs that is used by parent and child in a… heap sort.c fixed the issue increment_number.c Added New File: increment_number.c ip_address.c Create ip_address.c isInputLeapYear.c Create is...
Write a program in C to find the sum of digits of a number using recursion. Pictorial Presentation:Sample Solution:C Code:#include <stdio.h> int DigitSum(int num); int main() { int n1, sum; printf("\n\n Recursion : Find the sum of digits of a number :\n"); printf("---\n...
Find Sum Of Digits Find Sum Of First Nth Natural Number's Tilling Problem Using Recursion Tower Of Hanoi Problem Using Recursion Problem Statement Based Question : Best Time to buy and sell stock's Best time to buy and sell stock's 2 GCD Using Euclidean Algorithm Longest Increasing Subsequences...
C program to reverse a string using recursion C program to reverse every word of the given string C program to remove a given word from the string C program to delete duplicate words in the string C - Sort strings in alphabetical order C - Find frequency of given word in a string C -...
fork() Example - C program demonstrating use of fork() in Linux In the following example, we are demonstrating the use of thefork()function: Consider the example #include <stdio.h>#include <unistd.h>intmain() {intid; printf("Hello, World!\n"); id=fork();if(id>0) {/*parent proc...
In mathematics, the Fibonacci series is formed by the addition operation where the sum of the previous two numbers will be one of the operands in the next operation. This computation will be continued up to a finite number of terms given by the user. The computation will be performed as: ...
Find ASCII Value of Character Using gets() function If-Else Switch Case Checking for Vowel Reversing Case of Character Swapping Two Numbers Largest and Smallest using Global Declaration Loop Basic for Loop Basic while Loop Basic do-while Loop Nested for Loops Program to find Factorial of number...