in GATE retagged by
367 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$
in GATE retagged by
by
367 views

4 Comments

@Arjun sir, someone changed the options.
0
0

@Arjun sir please change the options.

0
0

@Utkarsh Joshi

WHy isn't D)  k%u is right ??

0
0

D is correct! @jatin khachane 1

0
0

1 Answer

1 vote
1 vote
Best answer

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

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

64.3k questions

77.9k answers

244k comments

80.0k users