Bifalgorithm post · Computer science one · Normalizing a Number

How can a while loop normalize a number in PHP?

How can a while loop normalize a number in PHP? (Computer science one · Normalizing a Number) — "Let’s revisit the example from Section 4.1.1 in which we norma…

Ideas in this flowchart

  • Normalizing a number with a while loop in PHP
  • Initialization of the normalization process
  • The variable x is initialized to 32145.234
  • The counter k is initialized to 0
  • The loop continues while x is greater than 10
  • The current value of x is divided by 10
  • The counter k is increased by 1
  • When the condition is no longer true, the loop stops
  • The code works equally well with any value of x
Feed/

How can a while loop normalize a number in PHP?

No cover

Channel

Computer science one

1 page

"Let’s revisit the example from Section 4.1.1 in which we normalize a number by continually dividing it by 10 until it is less than 10. The code in Code Sample 39.5 specifically refers to the value 32145.234 but would work equally well with any value of $x.\n\n1 $x = 32145.234;\n\n2 $k = 0;\n\n3 while($x > 10) {\n\n4 $x = $x / 10;\n\n5 $k++;\n\n6 }\n\nCode Sample 39.5.: Normalizing a Number with a While Loop in PHP"

Flowchart preview
👍
0
0 comments0 shares

Sign in to view and post comments.