Skip to main content
Engineering LibreTexts

7.5: Exercises

  • Page ID
    35833
  • Exercise \(\PageIndex{1}\)

    Write the code to examine the value of the variable X. If it’s less than zero, the message negative value should be printed.

    Exercise \(\PageIndex{2}\)

    Write the code to examine the value of the variable X. If it’s equal to zero, the message zero value should be printed.

    Exercise \(\PageIndex{3}\)

    Write the code to compare the values of the variables X and Y. The greater value should be printed.

    Exercise \(\PageIndex{4}\)

    Write the code to examine the values of the variables X and Y. If both X and Y are greater than zero, increment X by one.

    Exercise \(\PageIndex{5}\)

    Write the code necessary to print the message Error! six times but without using six sequential printf() calls.

    Exercise \(\PageIndex{6}\)

    Write the code required to control a loop so that it continues so long as the variable K is less than 50.

    Exercise \(\PageIndex{7}\)

    Write the code needed to cycle the variable R from 100 to 200 in steps of 5 (i.e., 100, 105, 110, etc.).

    Exercise \(\PageIndex{8}\)

    Explain the practical difference between a while loop and a do-while loop.