Ask Question
28 October, 13:29

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.

+1
Answers (2)
  1. 28 October, 13:45
    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. 28 October, 16:18
    0
    credits = (credits < 0) ? 0 : credits;

    Explanation:

    This is the ternary conditional operator.
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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers