Ask Question
15 March, 11:32

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.

+5
Answers (2)
  1. 15 March, 12:04
    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;

    }
  2. 15 March, 12:54
    0
    credits = (credits < 0) ? 0 : credits;

    Explanation:

    This is the ternary conditional operator.
Know the Answer?
Not Sure About the Answer?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers