Computer Science, asked by 20bca169, 6 months ago

int f(int x) {
return x*2 - 1;
}

int h() {
int a = 3;
int b = f(a) + f(4);
return b;
}
what is the output of this coding?

Answers

Answered by sonalip1219
0

Answer:

CODING

Explanation:

The given coding is:

int f(int x) {

return x*2 - 1;

}

int h() {

int a = 3;

int b = f(a) + f(4);

return b;

}

According to the coding, we have

  • f(x)=x^2-1
  • a=3 and b=f(a)+f(4)

We have to find the output of the given coding.

That means, we have to find the value of b.

We have, b=f(a)+f(4).

Therefore, we get

                                              b=f(a)+f(4)\\b=a^2-1+f(4)\\b=3^2-1+4^2-1\\b=9-1+16-1\\b=23

So, the output of the coding will be 23.

Answered by shilpa85475
0

Error: Runtime error.

The function int f(int x)  is defined before the int h() function.

But here, for the output there should be main class that is public static void main(String args[]) class.

In that class both of this function should be called by making use of the object of the class.

Explanation:

int f(int x) {

return x*2 - 1;

}

int h() {

int a = 3;

int b = f(a) + f(4);

return b;

}

the public class should be added firstly.

After that both of this function will get called in public static void main (String args[]) class

Then declare the object of the class for eg, abc is the class a is the object of the class .

Then call the function by a.int f(10);

and a.h();

Similar questions