Ask Question

Write a statement that increments (adds 1 to) one and only one of these five variables : reverseDrivers parkedDrivers slowDrivers safeDrivers speeders.

The variable speed determines which of the five is incremented as follows:

The statement increments reverseDrivers if speed is less than 0, increments parkedDrivers if speed is less than 1, increments slowDrivers if speed is less than 40, increments safeDrivers if speed is less than or equal to 65, and otherwise increments speeders.

+1
Answers (1)
  1. 23 July, 16:00
    0
    int reverseDrivers, parkedDrivers, slowDrivers, safeDrivers, speeders;

    int speed; / / variable declaration

    if (speed<0) / / checking condition

    reverseDrivers++; / / increment the value by 1

    else if (speed<1) / / checking condition

    parkedDrivers++; / / increment the value by 1

    else if (speed<40) / / checking condition

    slowDrivers++; / / increment the value by 1

    else if (speed<=65) / / checking condition

    safeDrivers + +; / / increment the value by 1

    else

    speeders++; / / increment the value by 1

    Explanation:

    Following are the description of statement

    Declared a variable reverseDrivers, parkedDrivers, slowDrivers, safeDrivers speeders and speed of integer types. These variables increments its value by 1 according to the condition of the speed variable. Speed variable check the condition of speed. if (speed<0) it increment the value by 1 in the "reverseDrivers" variable. if (speed<1) it increment the value by 1 in the "parkedDrivers" variable. if (speed<40) it increment the value by 1 in the "slowDrivers" variable. if (speed<=65) it increment the value by 1 in the "safeDrivers " variable. if all the if block condition fails then control moves to the else block and increment the value by 1 in the "speeders " variable.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a statement that increments (adds 1 to) one and only one of these five variables : reverseDrivers parkedDrivers slowDrivers ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers