Mysterious Boxes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include <iostream>
using namespace std;
int func(int N, int M){
    while(N [Box1] M){
        N [Box2] M;
    }
    return N;
}
int main(){
    cout<<func(3,3);
    cout<<func(7,3);
    cout<<func(5,3);
    return 0;
}

0 1 2

What are the operators hidden in the boxes in line 4 and 5 of the C++ program above such that you get the desired output ? (Enter the operator numbers, described below, as answer like Box1Box2)

1
2
1. ==    2. !=    3. <      4. >      5. >=     6. <=
7. /=    8. *=    9. +=    10. -=    11. &&    12. ||


The answer is 510.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Hasmik Garyaka
Oct 19, 2017

func returns N%M, in the first box is true predicate for all inputs, it's >=. To calculate modulus we can subtract second number from first.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...