Give the output of the following method definition and also write what mathematical operation it carries out: void test2(int a, int b) { while( a != b) { if ( a > b) a = a - b; else a = b - a; }
Advertisements
प्रश्न
Give the output of the following method definition and also write what mathematical operation it carries out:
void test2(int a, int b)
{
while( a != b)
{
if ( a > b)
a = a − b;
else
a = b − a;
}
System.out.println(a);
}
if 4 and 17 are passed to the function.
संक्षेप में उत्तर
Advertisements
उत्तर
1
(The mathematical process performed is to display the HCF of two numbers).
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
