97.2k views
2 votes
The following code processes a file containing five positive numbers. What will the variable $result contain after the code is executed? Be careful! $result = 0; $someFile = fopen("some-file.txt", "r"); for ($count = 1; $count <= 5; $count = $count + 1) { $nextNum = fgets($someFile); } $result = $result + $nextNum; fclose ($someFile); print ("

The result is $result

");

User Hina
by
5.4k points

1 Answer

1 vote

Answer:

highest of five numbers in the file

Step-by-step explanation:

  • This code reads the file "some-file.txt" and saves the result in variable "somefile"
  • The runs a for loop for a count of 5.
  • In each loop it compares the current value of the file with the value of the variable result and if the result is true it updates the value of the variable result.
  • At the end of this code the variable result will contain the highest value in the file "some-file.txt" and print it.

User Tseng
by
5.4k points