Questions tagged [ifstatements]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
11 views

Running an 'if' statement inside of a 'for' loop; Need to continue loop w/o printing anything, but not sure what value to return

So, I'm currently working on 'Substitution', and have written the following code to evaluate if a certain array of characters are all alphabetic: for (int i = 0; i < length; i++) { if (isalpha(...
  • 3
0 votes
2 answers
41 views

Else If Boolean Statements of Equality In the Case of Complex Numbers

In the lecture for Week 1, Professor Malan said that in an if statement, the third boolean expression (else if (x ==y)) is redundant or implied, since logically, if it is false that a number is ...
0 votes
1 answer
63 views

If statement: evaluating if my variable equals one of 2 values (C)

I am trying to evaluate if my two variables each match one of multiple values in an if statement. I'm trying: if ( ( variable1 == A || B ) && ( variable2 == C || D ) ) Error: use of ...
  • 1
0 votes
1 answer
13 views

Pset 7 if statement issue

I have an issue with an if statement that does not match condition in my application.py. However, when I test the same statement in a test script with real values instead of variables, it works as ...
  • 5
1 vote
1 answer
151 views

What is the logical difference between if (isupper(text[i]) == true) and if (isupper(text[i]))?

In my original code I had this: if (isupper(text[i]) == true) { int j = (int) text[i] % 65; int k = (j + key) % 26; char l = (char) k + 65; ...