0% found this document useful (0 votes)
2 views4 pages

Software Testing Flow

The document provides advice on correcting syntax errors and logical issues in PHP code related to loops and functions. Key points include fixing for-loop syntax, ensuring proper return statements, and correctly checking if a number is a power of two. The document emphasizes the importance of proper parameter usage and condition checks in function definitions.

Uploaded by

Emmanuel Hayford
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Software Testing Flow

The document provides advice on correcting syntax errors and logical issues in PHP code related to loops and functions. Key points include fixing for-loop syntax, ensuring proper return statements, and correctly checking if a number is a power of two. The document emphasizes the importance of proper parameter usage and condition checks in function definitions.

Uploaded by

Emmanuel Hayford
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Advice as a software tester

1. The for-loop syntax is incorrect. From the code it only has one argument which is the
condition and missing the other two arguments which are the initialization and
increment/decrement counter. The correct syntax for loop is
($i = 0; $i < 32; $1++)
2. There is a syntax error on line 8 the (print_r) statement is missing a closing bracket
before the semicolon. The outcome should be
3. The reverse integer function needs to return the result so the outcome should be return
$result;
4. The outcome should be print_r(reverse_integer(1234). “
Start

Input n

result = 0

i=0

i < 32?

Yes
No
$result << = 1
End

$result |= ($n & 1

$n >> = 1
Advice as a software tester

1. The function PowerOfTwo() is missing a parameter or an argument it should be


(PowerOfTwo($n).)
2. The condition in the if statement is incorrect. The logic must check if a number is the
power of 2. The code error is missing the $n variable so the correct condition should be
```php
if( ( n>0 & (n-1) == 0 ) )
```
3. On line 6 and 10, the output string is missing a return statement. The correct code should
be (return “$n is the power of 2”) and (“$n is not the power of 2”).
4. The outcome of the result should be
print_r(PowerOfTwo(4). “\n”)
print_r(PowerOfTwo(3). “\n”)
print_r(PowerOfTwo(16). “\n”)
Start

Input n

Is n the
power of 2?

print n is not the power


print n is the power of 2
of 2

End

You might also like