Anonymous
Anonymous asked in Computers & InternetProgramming & Design · 4 weeks 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
    4 weeks ago
    Favorite 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.

    • Log in to reply to the answers
  • 4 weeks ago

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

    • ...Show all comments
    • Quentin
      Lv 7
      4 weeks agoReport

      bool pass = false;
      if (mossVerd1 == 0) {
                assignmentOne = 0;
      } else { pass = true; }
      if (mossVerd2 == 0) {
                assignmentTwo = 0;
      } else { pass = true; }
      if (mossVerd3 == 0) {
                assignment = 0; // and change operator
      } else { pass = true; }

    • Log in to reply to the answers
Still have questions? Get answers by asking now.