Ask Question
2 November, 15:52

Write a conditional expression that assign the value 0 to a credits variable if it is less than 0; otherwise the value of the credits variable remains unchanged.

+2
Answers (2)
  1. 2 November, 15:54
    0
    credits = (credits < 0) ? 0 : credits;

    Explanation:

    This is the ternary conditional operator.
  2. 2 November, 16:09
    0
    void updateCredit (float credit) {

    if credit < 0.0

    credit = 0.0;

    }

    Explanation:

    I am going to write a C function for this.

    The input is your credit value, and it has just a conditional to verify if it is not negative.

    void updateCredit (float credit) {

    if credit < 0.0

    credit = 0.0;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a conditional expression that assign the value 0 to a credits variable if it is less than 0; otherwise the value of the credits ...” 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