Anonymous
Anonymous asked in Computers & InternetProgramming & Design · 8 months ago

Help with programming (c)?

Im currently writing multiple "if" statements as follows

if (mossVerd1 == 0) {

          assignmentOne = 0;

}

if (mossVerd2 == 0) {

          assignmentTwo = 0;

}

if (mossVerd3 == 0) {

          assignment == 0;

}

However, I want another statement that if all the above are true, aka for each Moss Verdict 0 is imputed, for a print statement to pop up to say they cannot pass the course.

Update:

sorry meant to say "aka if each Moss Verdict imputed is 0" I'm very tired lol

2 Answers

Relevance
  • EddieJ
    Lv 7
    8 months ago
    Favourite answer

    The general answer is:

    if (mossVerd1 == 0 && mossVerd2 == 0 && mossVerd3 == 0)

    However, if the values are never negative, you could use:

    if ((mossVerd1 + mossVerd2 + mossVerd3) == 0)

    If you know about arrays, you might want to consider using an array instead of numbered variables.

  • 8 months ago

    you have 'if' uesd not uesd 'else'. 

Still have questions? Get answers by asking now.