Q43: What does the given C program do?

Question #43: What problem is the below C program trying to solve?

C-program

Options:

  • The program tries to find positive integer solutions to x^2 + y^2 = z^2, that is, Pythagoras theorem.
  • The program tries to find the value of ‘n’ for given values of ‘x’, ‘y’ and ‘z’ for the equation x^n + y^n = z^n by printing “hello, world\n”.
  • The program tries to find the values of ‘x’, ‘y’ and ‘z’ for a given ‘n’ by printing “hello, world\n”.
  • None of the above.

Solution: For the given input ‘n’ by the user, the program is trying to find the values of x, y and z which satisfy the equation x^n + y^n = z^n. In fact, this is the statement of Fermat’s last theorem. Hence third option is the correct one.