Math, asked by brijwasianjali1135, 1 year ago

Consider the function: find (int x, int y) { return((x < y) ? 0: (x – y)); } let a, b be two non-negative integers. the call find(a, find(a, b)) can be used to find the: (a) maximum of a, b (b) positive difference of a, b (c) sum of a, b (d) minimum of a, b

Answers

Answered by frank55oops
4
(d) minimum of a,b

#include<stdio.h>int find (int x, int y) {    return((x<y) ? 0 : (x-y));}int main() {
   int c;   c=find(3,find(3,9));   printf("%d\n",c);   return 0;}
Answered by RitaNarine
8

Given:

find (int x, int y) { return((x < y) ? 0: (x – y));

To Find:

Output of find(a,find(a, b)).

Solution:

The function ((x < y) ? 0: (x – y)) , returns 0 if x <y and returns x -y , if x > y.

Keeping this in mind ,

  • find (a,b) will give 0 if a < b and a- b if a > b

Therefore,

  • find(a ,  find(a,b)) gives:
  • 0 if a < find(a,b) and
  • a - find(a,b) if a > find(a,b)

Applying the first find function,

  • find(a,find(a,b)) :
  • 0 if a < 0 or a < a -b ie b < 0
  • a - 0 if a> 0 and a <b
  •  or a - (a - b) = b , if a > a -b  and a>b ie, b > 0

Since a and b are two non negative integers, find(a,find(a,b)) gives minimum of a and b.

Similar questions