retagged by
389 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

356
views
1 answers
2 votes
Bikram asked Feb 9, 2017
356 views
Read the below code snippet: int joo( int num ) { int result = 0 ; if ( num <= 1) return 1; else { for ( i=num; i >= 1; i - - ) { result + = joo( i / 3) ; } } return result; }When $num = 6$, the return value of the function is _____.
248
views
1 answers
2 votes
Bikram asked Feb 9, 2017
248 views
What is the output of the below mentioned code snippet?void goo(char *p) { if( p[0] = = '\0') return; goo(p+1); goo(p+1); printf("%c", p[0]); } main() { goo("123"); } $3$ $3$ ... $3$ $2$ $3$ $3$ $2$ $1$ $3$ $3$ $3$ $1$ $3$ $3$ $2$
352
views
1 answers
2 votes
Bikram asked Feb 9, 2017
352 views
Read the following statements carefully: Studies show that there is hardly any difference between human beings and apes in their psychological capacities. ... clear difference between the psychological capacities of human beings and apes.
806
views
3 answers
3 votes
Bikram asked Feb 9, 2017
806 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, therefore, is ₹ _______.