retagged by
341 views
0 votes
0 votes

The following function finds the $GCD$ recursively.
 

int GCD(int k, int u)
{
if( u = = 0 )
return k ;
else
return GCD( u , ____);
}

Fill in the blank with the most appropriate function:

  1. $k/u$     
  2. $u/k$    
  3. $u \% k$
  4. $k \% u$
retagged by

1 Answer

Best answer
1 votes
1 votes

To calculate GCD of two numbers , we write the following code :

#include <stdio.h>
int hcf(int n1, int n2);
int main()
{
   int n1, n2;
   printf("Enter two positive integers: ");
   scanf("%d %d", &n1, &n2);

   printf("G.C.D of %d and %d is %d.", n1, n2, hcf(n1,n2));
   return 0;
}

int hcf(int n1, int n2)
{
    if (n2 != 0)
       return hcf(n2, n1%n2);
    else 
       return n1;
}

so it is k%u in our question, which is option D .

selected by
Answer:

Related questions

2 votes
2 votes
1 answer
1
2 votes
2 votes
1 answer
2
3 votes
3 votes
3 answers
4
Bikram asked Feb 9, 2017
718 views
A radio is available at $\text{₹} 27780/-$ cash price, or three equal annual installments at $15\%$ per annum under $CI$ compounding annually. Each installment amount, ...