Assume that a bool variable isQuadrilateral has been declared , and that an int variable , numberOfSides has been declared and initialized . Write a statement that assigns the value true if numberOfSides is exactly 4 and false otherwise.

2
Assume  that a bool variable  isQuadrilateral has been declared , and that an int  variable , numberOfSides has been declared  and initialized . Write a statement  that assigns  the value  true  if numberOfSides is exactly 4 and false  otherwise.

LANGUAGE: C++

CHALLENGE:

Assume  that a bool variable  isQuadrilateral has been declared , and that an int  variable , numberOfSides has been declared  and initialized . Write a statement  that assigns  the value  true  if numberOfSides is exactly 4 and false  otherwise.

SOLUTION:


</pre>
if (numberOfSides == 4){
 isQuadrilateral = true;
}else{
 isQuadrilateral = false;
}
<pre>

2 comments

Add comment