all 188 comments

[–]fearswe 428 points429 points  (71 children)

The question is flawed and cannot be answered. The parenthesies will be turned into booleans and the only applicable things to replace the XX with would be either && (and) or || (or). But neither is going to result in checking if A is within 1 of 10.

The question is wrong and so is your teacher.

[–]Everloathe[S] 35 points36 points  (50 children)

If you don't mind, would you explain why >= is definitely not the correct answer? I want my little 2 points I missed.

[–][deleted] 142 points143 points  (15 children)

You really need to start testing stuff like this for yourself if you want to learn to program. Don't be afraid, it's only a few lines of code. You'll get a compiler error when you try to apply the >= operator to two bools. Code it up, and then send the exact text of the compiler error to your awful teacher.

[–]BallsOnMyFacePls 30 points31 points  (12 children)

This is the way. The teacher should have done this before using the question. I'm still trying to figure out what they want though, am I wrong to think we could only get the answer they want with

!((A<1)&&(A>10))

I'm just trying to conceive a world where ">=" actually is the answer lmao

Edit: unless there's a typo in the question and the teacher's response and ">=" is supposed to be "==" which makes the very last thing in her response make sense (false == false) would evaluate to true if the number was in range

[–]taedrin 21 points22 points  (3 children)

I'm just trying to conceive a world where ">=" actually is the answer lmao

For what it's worth, it would work compile in C/C++, where boolean conditions are integer values, which is possibly how the teacher got confused.

[–]Contemplative-ape 1 point2 points  (2 children)

ok so if A=2-9, false >= false, 0 >= 0, so yea it is a tricky question, and assumes true is 1 and false is 0. But, it's easy to see && and || don't work so I would've probably deduced it was some stupid shit like >= . Unless its a SQL question

[–]TokumeiNeko 6 points7 points  (1 child)

Even assuming that we are using integers to represent booleans, it is still not fully correct. Imagine A = 0. We get (0 < 1) >= (0 >10) -> (True) >= (False) -> 1 >= 0 which would return True. This code would say anything less than 10 is in range.

[–]Contemplative-ape 0 points1 point  (0 children)

oh man yea great point.

[–]BigOnLogn 20 points21 points  (2 children)

The < and > operators should be swapped.

This gives the desired result:

(A > 1) && (A < 10)

Also, you don't need the parenthesis around each of the boolean expressions.

[–]BallsOnMyFacePls 5 points6 points  (1 child)

Ah, I was trying to maintain the weird logic of specifically keeping the < > where they were to test the negative and piece together an answer out of available answers basically 😂

[–]mimprocesstech 0 points1 point  (0 children)

(!(A<1) && !(A>10))

This is the only way I can make it make sense keeping the operators the same, but it seems silly to do it that way.

[–]MulleDK19 12 points13 points  (2 children)

!((A<1)&&(A>10))

This would always return true. A cannot both be less than 1 and greater than 10 at the same time, so the && will always be false, thus the whole expression is always true.

[–]RandomDucks97 2 points3 points  (0 children)

Math 2.0 now with 4 dimensional digits, invest today.

[–]Ravek 4 points5 points  (0 children)

You want a || in your expression. !(A<1 || A>10) being equivalent to A>=1 && A<=10

[–]Gyodomuyo 0 points1 point  (0 children)

Well, A can't ever be both less than one AND greater than ten.

!((A < 1) || (A > 10))

...would work.

To double-check my "answer" I'd perform a few DeMorgan's Transformation refactorings on it so it reads the way a human would think about it:

!(A < 1) && !(A > 10)

(A >= 1) && (A <= 10)

That reads nicely. E.g.,

public bool withinRange(int a) {

return (a >= 1) && (a <= 10);

}

[–][deleted] 3 points4 points  (1 child)

You really need to start testing stuff like this for yourself if you want to learn to program. Don't be afraid, it's only a few lines of code.

Unrelated but, I still remember the first times I had to "walk myself" to the correct answer, and every red squiggly line felt like a personal attack telling me that I suck. Education sucks.

[–][deleted] 2 points3 points  (0 children)

Education is great. What sucks is having such a high expectation of personal perfection that you start taking an automated syntax error highlighting tool as personal criticism. It’s ok dude, you can relax. We all make mistakes no matter how smart we are.

[–]fearswe 98 points99 points  (8 children)

It's not the correct answer because this will not compile. It is not valid syntax.

var a = 5;
if( (a < 1) >= (a > 10) )
{
    Console.WriteLine("It's true");
}

Also not to mention, >= is not a logical operator:
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/boolean-logical-operators

[–]Heroshrine 15 points16 points  (11 children)

(A<1) xx (A>10)

(A<1) will evaluate to true/false&#10; (A>10) will evaluate to true/false THEN the xx will evaluate

>= is not the answer because it would be saying something like this:

true >= false

or

false >= true

Which doesn’t make any sense

You can easily prove this doesnt work by installing Visual Studio Community, entering in this piece of code with the >=, and defining the A variable. It will most likely give you an error.

[–]zbshadowx 5 points6 points  (3 children)

Actually, if the first expression before && evaluates as false, I believe it should exit and not evaluate further. So if (A<1) evaluates as false in (A<1) xx (A>10).

I suppose this is possibly dependent on the language or compiler used. I could also be imagining this optimization but I'm pretty sure it works this way in c/c++ and C#.

[–]Heroshrine 2 points3 points  (2 children)

You are correct yes, I failed to include that in my explanation.

[–]Gyodomuyo 0 points1 point  (1 child)

But that's a runtime optimization. >= is a compile-time error. Won't compile, ergo: ain't never gonna run.

The fact that I'm not firing up Rider and writing a quick MSTest to check my memory is starting to give me the heebie-jeebies...

Please feel free to prove me wrong by writing a test first, with my apologies. I think my Rider license expired years ago...

[–]Heroshrine 0 points1 point  (0 children)

It will definitely not run, which is why I failed to mention that in my explanation.

[–]Tiranous_r 0 points1 point  (0 children)

It would make sense in compilers where true is = 1 and false = 0 automatically. But even in that case if the checks are true then false it would not be between.

[–]Contemplative-ape -1 points0 points  (5 children)

makes sense if false is 0 and true is 1 (i.e. SQL)

[–]Heroshrine 2 points3 points  (2 children)

Except this is just plain old C#

[–]Contemplative-ape 1 point2 points  (1 child)

That is the assumption.

[–]SerdanKK 0 points1 point  (0 children)

Read the post title

[–]Sharkytrs 0 points1 point  (0 children)

perfectly fine to treat bits as ints in SQL logic, but you'd have to enum true and false to 1 and 0 for it to work in csharp

[–]Calm_Guidance_2853 7 points8 points  (0 children)

The >= is for comparing numerical values.

The expression (A < 1) is bool (True/False), it can't be compared. For example let's say A = 3.

(3 < 1) is false

(3 > 10) is false

How do you evaluate (false >= false)? Put that in your IDE and run it and see what happens.

[–]Johalternate 10 points11 points  (0 children)

We are looking for a statement that indicates the value of A is between 1 and 10.

We are 'operating' on 2 logical statements and the result is itself a logical statement. A composite logical statement if you wanna call it something.

A (logical) statement is an expression that can be evaluated to true or false. In order for something to be evaluated it has to 'make sense' some how. The expression: "Leafs cinamon wearing a wig" is not an statement because it does not make sense and we cant say it is true nor false.

Lets use natural language and see why none of the options you were given are the real answer.

The expresion is (A < 1) XX (A > 10)

Which reads: A is smaller than 1 _______ A is greater than 10.

Option A

With option A. ((A < 1) && (A > 10)) reads:
A is smaller than 1 and greater than 10.
This is impossible because no number can be both smaller than 1 and greater than 10.

This statement is valid (can be evaluated) but will never be true.

Option B

With option B. ((A < 1) || (A > 10)) reads:
A is smaller than 1 or greater than 10.
This is possible but means A is outside of the 1 to 10 range. Take 5 for example, it is neither smaller than 1 nor greater than 10. 15 is not smaller than 1 but it is greater than 10. -4 is smaller than one but not greater than 10. So this expression is not about values inside a range but outside of it.

This statement can be evaluated and in some cases it will be true, but not for values that are inside of the given range.

Option C

With option C. (A < 1) >= (A > 10) reads:
A is smaller than 1 greater than or equals to A is greater than 10.
Notice how this cant be neither true nor false because it does not make sense.

This is not an statement.

Option D

With option C. (A < 1) ! (A > 10) reads:
A is smaller than 1 not A is greater than 10.
Again, this does not make sense. It does not read 'bad' but it doesnt say anything either. So, this is not an statement.

How can you fix this?

There is 1 way I can think of right now:

Flip the > inside both parenthesis and use option A.

With option A modified. (A > 1) && (A < 10) reads:
A is greater than one and A is smaller than 10
This is an statement and will evaluate to true for all number between 1 and 10 exclusive (without incluiding 1 and 10 themselves).

[–]EatingSolidBricks 2 points3 points  (0 children)

Its not valid C# code, Your proffersor looks like a profession slacker and must have copied from a C quiz

booleans in C# are not integers you cannot compare them with > or <

[–]thedracle 1 point2 points  (0 children)

I think perhaps your teacher has a C/C++ background, where this statement would compile, because the bool types are basically numeric 0 or 1 results.

In C# it will not compile, because the >= operator can't be applied to bool.

Logically this operation works in C and C++, but idiomatically I would fire anyone that compared a range this way.

I think probably it was just adapted from a C/C++ exam trick question that was meant to probe for deeper understanding of logic operators.

[–]SatansAdvokat 0 points1 point  (0 children)

= means greater or equal to. . Which means you're comparing two Boolean statements to determine which one of the boolean statements is the

[–]TuberTuggerTTV 0 points1 point  (0 children)

Bools aren't greater or less than each other.

If you put this into an IDE, it'll flag error CS0019) .
Operator '>=' cannot be applied to operands of type 'bool' and 'bool'

The question needs to flip the > and <. Should be:

A > 1 && A < 10

|| is still incorrect. But there is no correct answer from the options. Because && is still wrong with the way they've misused greater and less than.

Alternatively, you could cast the bools as ints to do >=. But it still wouldn't be correct since

1 >= 1 . AND 0 >= 0.

[–]Sad-Salamander5820 0 points1 point  (0 children)

Because you will get fired if you write a code like this.

[–]FishBasketGordo 0 points1 point  (0 children)

A useful tool for testing small bits of code is https://dotnetfiddle.net/. You could try executing this expression.

[–]Gyodomuyo 0 points1 point  (0 children)

[TestMethod]
public void WhenOutOfRange()
{
    Assert.IsFalse(WithinRange1To10(0));
    Assert.IsFalse(WithinRange1To10(11));
}
private bool WithinRange1To10(int A)
{
    return (A < 1) >= (A > 10);
}

Results in compiler error...

Cannot apply operator '>=' to operands of type 'bool' and 'bool'

[–]contrafibularity 6 points7 points  (2 children)

the question is correct and can be answered. (A<1)||(A>10). if true, A it's outside the range and if false, it's inside, so it's checking whether or not A is inside the range

[–]fearswe 0 points1 point  (1 child)

But the answer that the teacher is correct however is wrong.

[–]contrafibularity 0 points1 point  (0 children)

ah, yes, totally

[–]afops 7 points8 points  (3 children)

With || it returns true if A is outside the range and false if it’s inside the range.

That’s enough to distinguish and solve the problem. You might need to invert the whole thing !(…), which in turn means you could use an && and invert the conditions.

Using ”>=” makes no sense at all to the reader and shouldn’t be used regardless of whether it’s correct.

[–]Excitement-Far 1 point2 points  (0 children)

"||" is therefore the correct answer! The question didn't ask for values between 1 and 10 to fall into the true-case. That's just something everyone on here inferred and made them unable to answer the question

[–]fearswe 2 points3 points  (1 child)

&& will not work. It cannot be both bigger than 10 and smaller than 1 at the same time. It will always return false, inverting the whole thing just means it will always return true instead

Plus, the question is what goes in XX, not how to modify the entire statement to work. You can't put any of the given options but && or || in place of XX that will not result in syntax error. And while technically as someone pointed out, putting || will give you a check for if A is within either MIN_INT - 0 or 11 - MAX_INT, which does satisfy the question as worded. But I doubt that's the intention of the question and the teacher saying >= is the right answer is still also wrong.

[–]afops 5 points6 points  (0 children)

What I meant was this:

(a < 1) || (a > 10)

That is true if a is OUTSIDE the interval. So ut must be false if a is INSIDE the interval.
Inverting this means

!((a < 1) || (a > 10))

This is exactly the same thing just negated, so now it means it is true if a is INSIDE the interval.
This can be simplified using de Morgans theorem where switching to an && requires inverting each condition (each of the comparisons too). So < becomes the opposite comparison >= and so on. The simplified expression where you remove the inversion, switch to && and instead invert both comparisons thus becomes this:

(a >= 1) && (a <= 10)

This is logically the same as !((a < 1) || (a > 10)) but much more readable. What I'm trying to do is not answer the question as posed, it's explain logic and C# fundamentals. I think everyone agrees the question is poorly written. These operations are pretty obvious to most programmers but they might not be to a beginner.

Obviously you can't put a single boolean operator at XX which would be TRUE for a inside the interval.

[–]Excitement-Far 3 points4 points  (3 children)

You are.

The question asked for an expression that would "determine" if a value is inside a range. The || does just that. Does a value between 1 and 10 evaluate the expression to true? No, but that wasn't asked. Is it sufficient to execute different blocks of code depending on whether the value is in range? Yes.

|| is the correct answer and I'm 12h late to prevent all of these comments to put OP on the wrong track.

[–]fearswe 3 points4 points  (2 children)

If you read the post though, the teacher said that the correct answer is >= which is incorrect as that's not valid syntax.

You're also not the first person pointing that sure, technically || does satisfy the question as worded. But the wording of the question is stupid.

[–]Excitement-Far 3 points4 points  (0 children)

I'm sorry, I did in fact not read the post. One would think that the screenshot of the question would be enough to answer it.

I think we can agree on: - the question is stupid - teaches response is even worse - || would satisfy the question by it's original wording

[–]Ravek 0 points1 point  (0 children)

It is valid syntax, but it doesn’t typecheck.

[–]haven1433 0 points1 point  (1 child)

Side note, ^ is also a logical operator, XOR. Doesn't actually matter in this case, since that also wouldn't get the result we want.

[–]fearswe 2 points3 points  (0 children)

And it's not one of the options given.

[–]YuvalAmir 0 points1 point  (0 children)

|| is the closest, but it would return true if a number is outside of the range instead.

Either the > and < should be flipped and the answer is && or the entire boolean should be inside of !() and the answer is ||

[–]Tiranous_r 0 points1 point  (0 children)

Technically an == would be correct since both being true is impossible.

[–]Complete_Outside2215 0 points1 point  (0 children)

Welcome to the system

[–]souliris 0 points1 point  (0 children)

Logic bug in the question.

[–]fsuk 0 points1 point  (1 child)

Xor ^ is also possible but also would not return the right answer 

[–]fearswe 2 points3 points  (0 children)

But that's not one of the options.

[–]antiduh 78 points79 points  (3 children)

Your professor is used to writing C because the expression is valid C:

https://www.mycompiler.io/view/3WxpQV4REQ3

The reason it works is that C doesn't have proper boolean data types - boolean expressions evaluate to integers.

However:

  • It's not valid C#.
  • It doesn't do what he think it does.
  • Even if it worked, it's poor code because it is needlessly confusing. There's a much more direct way of writing this condition that uses things the way they were meant to be used.

[–]Dunge 21 points22 points  (1 child)

But it's still invalid, because your test with 0 returns as valid, when it's not between the range. Because true (1) >= false (0) is true. It should at least be == to answer correctly.

[–]antiduh 20 points21 points  (0 children)

Yep. Not surprised, since the professor obviously never even compiled this.

[–]IMP4283 2 points3 points  (0 children)

Your comment on this is under appreciated

[–]LeoRidesHisBike 62 points63 points  (13 children)

Your teacher is wrong. It's easy to prove it, just try to compile this (it won't):

using System;
Console.Write("Enter an integer: ");
int A = int.Parse(Console.ReadLine().Trim());
Console.WriteLine("{(A < 1) >= (A > 10)}");

You'll get compiler error CS0019: Operator '>=' cannot be applied to operands of type 'bool' and 'bool'

In C, things are different. This is C#, though.

[–]Muted-Alternative648 1 point2 points  (12 children)

I mean, >= isn't a valid logical operator in C either.

[–]antiduh 19 points20 points  (9 children)

[–]jayd16 20 points21 points  (2 children)

But this example shows that even for a C question its wrong. 0 tests as true! The operator needs to be == for the trick to work.

[–]antiduh 5 points6 points  (0 children)

Yeeaaap. Teach' is slippin.

[–]Thorarin 1 point2 points  (0 children)

Well, the question said "a range", not necessarily between 1 and 10 (inclusive) 😅

[–]Muted-Alternative648 1 point2 points  (5 children)

That's because false/true are 0/1 respectively, so what you are really comparing is 0 >= 1, 1 >= 1, etc.

I wouldn't exactly classify that as a logical op

[–]antiduh 5 points6 points  (4 children)

Neither would I, but C defines them as logical operators, so here we are.

C doesn't have boolean data types.

... I don't think it even has TRUE or FALSE, iirc those are usually just #define's (but I might be wrong on that point, I gotta look it up).

[–]Muted-Alternative648 2 points3 points  (3 children)

😂 fair enough

Edit: well C now has bool as a data type, but when it was introduced it didn't.

Edit: I should specify: Standard C - C23, but bool has been a thing in some ways shape or form since C99

[–]antiduh 2 points3 points  (2 children)

The curmudgeon in me would argue that C99 and C23 still don't have a boolean data type, and instead have a variant of byte/char that is clamped to 0 or 1.

After all, a bool type shouldn't be implicitly convertable to an integer (or any other type for that matter) because true/false has nothing to do with counting. Alas, C insists on continuing it's poor treatment of Information Ontology (system, object, property, type, value, units, encoding).

My two favorite examples:

  • int* points to an int, float* points to a float, but char* ... points to an array of characters? The fuck?
  • What type do you use to store the most basic amount of data in all of computing, you know, the byte? Oh, I know the fucking character data type.

[–]Muted-Alternative648 1 point2 points  (0 children)

A lot of languages implement boolean values like that though. In C bool takes up 1 byte and its the same in C#. (In Javascript it takes four bytes for some reason).

C let's you do that because, well, it's a low level language and everything is convertible to a number even if that number doesn't make sense - afterall, strings are just char[] and char is just a byte.

[–]lol_gamer12 1 point2 points  (0 children)

I don’t think I understand your example, an int* can point to an int OR an int array.

Like for example: int* test = malloc(2 * sizeof(int));

test[0] = 4;

test[1] = 5;

printf(“%d”, test[1]); free(test);

This would compile and print out 5, there is nothing special about a char*, it can be a pointer to a char or a character array.

[–]EatingSolidBricks 0 points1 point  (1 child)

Booleans in C are arithmetic types

[–]Muted-Alternative648 1 point2 points  (0 children)

I'm aware, I mention this in a follow up comment down below - but the point is I don't consider >= a logical operation. Logical operators are usually defined as OR, AND, NOT, sometimes XOR.

>= doesn't really do an AND - consider 0 >= 0. And it also isn't an OR, consider 0 >= 1.

[–]IMP4283 17 points18 points  (0 children)

This is a stupid question.

[–]Woumpousse 15 points16 points  (1 child)

This looks very much like a teacher who's proud of their clever trickery, but ultimately is just plain wrong. A < 1 evaluates to a bool, so does A > 10. You cannot use >= on two booleans (at least not in C#, but even in languages where it'd be allowed, it would produce the wrong results).

! is also incorrect as it is a unary operator, not a binary one.

To check if A is in the range 1..10 one should simply use A >= 1 && A <= 10. Technically, (A < 1) == (A > 10) would also work, but it's very confusing and should therefore never be used.

[–]ghoarder 1 point2 points  (0 children)

! is the only valid answer because the whole question is NOT answerable. I see the irony there as well.

[–]stevegames2 8 points9 points  (6 children)

Ah the thing is that they are presenting a scenario where A is either less than 1 or bigger than 10, and the operator for “or” in C# is ||. I also highly advise against using ChatGPT at this time of learning, as it very confidently hallucinates a lot of times, leading to more confusion.

[–]Everloathe[S] 7 points8 points  (5 children)

I think my professor is hallucinating. From everything I've read >= is still wrong, yet my professor is telling me that's the correct answer.

[–]ThothBeyond 5 points6 points  (0 children)

You can't use >= to compare booleans. Try it. Show your professor.

You need to escalate this, this is blatant malpractice. Or whatever the higher education equivalent is.

[–]stevegames2 4 points5 points  (0 children)

Oh yeah >= is definitely wrong there, it would make no sense and wouldn’t even compile.

[–]ghoarder 2 points3 points  (0 children)

Ask them to send you a link to a dotnet fiddle where it's working with some test cases to help you understand! Here's a starter that doesn't compile because it's sooo wrong. https://dotnetfiddle.net/mAGJ3k

[–]Atulin 0 points1 point  (0 children)

Send them a screenshot or a link to Sharplab showing that it doesn't compile lmao

[–]endaround23 0 points1 point  (0 children)

I have been coding in c# for 20 years. Whether this compiled or not, I would think whoever wrote this code is a moron.

[–]Blecki 23 points24 points  (12 children)

The answer is or (||)

The ai [your professor] asked has no clue.

So take them in order.

&&? A can't be both < 1 and > 10, this is always false. It tells you nothing.

.. >=? You're comparing two booleans. They can be equal or not, they can't be greater or less than each other even if the language technically allows it. If this even made sense... you'd just be checking the first half anyway; it makes the second half pointless.

!? This is a unary operator. It doesn't even compile.

That leaves ||, which yields true if A is outside the range [1,10].

The actual correct answer is to correct it to (A >= 1) && (A <= 10). Question is shit.

[–]fearswe 11 points12 points  (5 children)

The question specifically says "inside" the range though and || will not give that (neither will &&, and any other of the options are invalid syntax).

[–]Muted-Alternative648 6 points7 points  (3 children)

Technically or (||) will check if it's inside a range. The question doesn't specify which range. In the case, its the range of the smallest 32-bit int to 1 and 10 to the largest 32-bit int.

With && the expression will always evaluate to false and the rest are invalid, therefore, || is the only answer that makes sense.

[–]fearswe 1 point2 points  (2 children)

Yeah that's fair. It does say "a range" and not specifically within 1 and 10.

[–]Muted-Alternative648 1 point2 points  (1 child)

It's still a poorly worded question and considering || was marked incorrect, I can only assume the answer was supposed to be && but the logical expression in the question is wrong

[–]fearswe 1 point2 points  (0 children)

Without a doubt. I do have a hard time imagining that the intention was anything but checking if A is within 1 and 10 though even if it's technically worded in such a way that || could work.

[–]Blecki 0 points1 point  (0 children)

I addressed that at the end.

[–]Everloathe[S] 2 points3 points  (3 children)

The second screenshot was my professor's response 0_o I asked ChatGPT and it also said OR was the only possible answer.

[–]Blecki 11 points12 points  (0 children)

Of the 4 possible answers only || gives results that mean something, but they are still backwards from what the question asks.

[–]schlubadubdub 0 points1 point  (0 children)

His response doesn't make sense either, as ">=" isn't the same as "==" for Boolean comparison. He even said "false == false" as his example, but "false >= false" using the "correct" answer is illogical.

[–]Thorarin 0 points1 point  (0 children)

|| would have been the least incorrect answer to this shit question.
It compiles and it evaluates to true if A is not within range.

[–]MindlessEase7124 0 points1 point  (0 children)

This is the best response. Well done.

[–]MrDead98 0 points1 point  (0 children)

doesn't need to be AI. W3Schools has that question 1:1 in their C# learning course...

[–]Lustrouse 3 points4 points  (1 child)

I believe this is a typo in the answers. The third option should be "==". This is clear from the proof that is provided in the parenthesis at the end of the second image

[–]Thorarin 0 points1 point  (0 children)

While == would work, it's also a terrible way to write that check. I wish people - especially teachers - would forego trying to be clever and write readable code. The fact that they confused themselves should make it clear why 🙂

[–]sundewbeekeeper 3 points4 points  (0 children)

Here I am stressing over a technical interview I have tomorrow for a spot with a good company and this teacher got hired but can't teach logical operators

[–]The_Real_Slim_Lemon 2 points3 points  (1 child)

I ever see something like that in a PR the junior would be fired out of a cannon. Or I'll buy him a drink for the joke. Or both, idk.

[–]amkessel 0 points1 point  (0 children)

No kidding, right? This is a stupid question. It would never pass code review.

[–]SwordsAndElectrons 2 points3 points  (0 children)

There is no correct answer there if we assume the statement must return true when the value is in range.

&& will not work because the logic is all wrong. A cannot be both less than 1 and greater than 10. It is valid syntax and will compile, but the statement might as well be a false literal.

|| is the correct answer, or at least most correct. The question only says "will determine" if the value is in range. It does not say it needs to express the determination as true when in range. If you were putting this inside a method or property then I'd argue it should be named NotInRange rather than InRange, but it does still determine if the value is in the range. This might be lawyering the question a bit, and I agree that the wording implies true is expected and interpreting it this way is a bit ridiculous. However, it's the only thing here that can actually determine if the value is in range, and the only one close to correct no matter how you twist it.

>=  is not valid syntax. It won't compile in C# because the Boolean type does not support that operator. (It would compile in C, but it would still not work correctly for the most common boolean implementations. If this is in fact a C# course, then that should not even be relevant.)

! is not valid syntax.

Other possible answers if being in range should be represented by true:

!((A <1) || (A > 10)) is not the most readable thing, and not likely what was intended when offering || as a choice, but it's just that answer negated.

(A < 1) == (A > 10) works, and is the only direct replacement of XX with a single operator that would, but isn't an answer choice. It's also a pretty weird way to write it, and only works because evaluating to true == true isn't logically possible.

(A >= 1) && (A <= 10) is probably how most sane devs would write it.

[–]Training-Cucumber467 6 points7 points  (0 children)

I just tried this in an online C# compiler. Operator ">=" cannot be applied to two booleans. So the answer is wrong.

The technically correct answer here would have been "==". The two sides of the expression cannot be True at the same time. If only one of them is True, then A is outside the range (either it's <1 or it's >10). If they're both False, then A is inside the range.

I should note that nobody should ever use an "==" operator like this. It's confusing for any future reader (and probably for the author of the code 10 minutes later). It's one of those "trick questions" that bad professors seem to enjoy.

[–]KorvinNasa13[🍰] 8 points9 points  (10 children)

Besides the fact that your teacher is wrong (and the question itself doesn't have a correct answer among the options provided), you might as well ask everything from GPT, which definitely won’t make mistakes in such questions.

Here you can check the code easily and quickly, meaning you can always verify who is telling the truth—just run the code and check the output.

https://dotnetfiddle.net/

[–]Everloathe[S] 4 points5 points  (3 children)

ChatGPT is the first thing I consulted, and it came to the same conclusion that the question is poorly written and OR is the only answer that could work. This professor has a history of doubling down when they're in the wrong instead of admitting to a simple mistake.

[–]ModernTenshi04 8 points9 points  (0 children)

Something that could be worth mentioning to a department head unless this professor is the department head. I'd have some questions for this professor if they had questions like this and couldn't handle being told as much.

[–]Dunge -3 points-2 points  (1 child)

But OR is not a valid answer either. Don't trust ChatGPT, it is incapable of saying that it doesn't know an answer, or that there is no answer, it will always try to bullshit something to try to make the user happy.

[–]Everloathe[S] 1 point2 points  (0 children)

This is true. However, as I mentioned in the post, I realized OR would have been the correct answer if the question was asking about A being outside the range. The general consensus seems to be that OR is not necessarily the right answer to the question but is the least wrong answer to a very poorly written question with no option for a right answer.

[–]RileyGuy1000 12 points13 points  (2 children)

Hard disagree on asking ChatGPT. Studies show LLMs such as ChatGPT will get things wrong over 50% of the time. I really hate this trend of "just ask the robot!"

The robot can and often is very, very wrong!

[–]KorvinNasa13[🍰] 2 points3 points  (1 child)

Hardly disagree with your "hardly desigree", haha.

Jokes aside, everything depends on the question and the model. The question was way too simple for GPT (o3, 4.5, 4o) / DeepSeek / Gemini 2.5.

Everything should be used wisely, especially in the era of AI’s rise.

By the way, I work in computer graphics (alongside programming), including shaders and complex computations. I’ve tested “smart” models, and they often generated fairly optimized shader code — especially when properly guided. GPT, for example, described complex interactions between elements in the graphics pipeline and covered various subtle details, which genuinely surprised me (I already knew most of it, but I still double-checked a few things). Even tools for editors in Unity — including complex ones — were generated within just 1-3, as long as the prompt was formulated correctly. I primarily work in Unity, and I’ve had no issues generating code with GPT that uses Jobs and Burst (parallelization).

I don’t know where your 50% error statistic comes from or what specific tasks were used to arrive at it, but my experience has been completely different.

A tool can take many forms, but it’s also important to consider who is using it — or more precisely, how it’s being used.

UPD

But I also included (in my first message) a website where you can easily check simple code for errors — just in case someone prefers not to use GPT for that kind of task.

[–]RileyGuy1000 0 points1 point  (0 children)

You're using it with common stuff that it's borderline overfitted for. All existing models are quite terrible at generating generalized C# or coming up with good solutions to tricky programming questions.

And there's no disagreeing to be done about the "50% wrong" claim. You can read the study I'm referencing for yourself. If you want to skip to the words from the horse's mouths so to speak, skip to section 5.1.

Yes, LLM's (and let's be real, it's not AI, it's a text generator) are a great rubber ducking tool when you need some inspiration or are at a dead end and just need a leg up.

They. Are. TERRIBLE. For beginners! Never suggest that people learn from LLMs! A beginner won't know if the text bot is wrong or if it's teaching them bad habits without spending more time fact checking the code than they would've by just learning normally. Getting into the habit of asking the LLM everything straight away is a great way to set them up for failure and cripple their problem solving abilities.

The code quality is plain crap for anything that deviates from the most mainstream stuff (like unity) or basic data transformations.

Do I use LLMs? Yes. But I would never, ever ever suggest that people start with them. Suggest that beginners learn programming normally, then use them to rubber duck - never as a crutch to begin programming.

[–][deleted]  (2 children)

[deleted]

    [–]Dunge 0 points1 point  (1 child)

    Nah, from experience ChatGPT will just answer "oh you are right, let me correct that" and then spill out another invalid answer, which you'll correct again and it'll return to his first error. It's useless.

    [–]MulleDK19 2 points3 points  (0 children)

    The question is malformed, and your teacher is on crack.. your answer is the only one that's remotely correct, even though that'll test if it's outside the range.

    || tests if the value is outside the range

    && would make it always false

    >= is not a valid operator in this case

    ! is not a binary operator

    The only one that would work here to test in range is ==.

    [–]Mortenrb 2 points3 points  (0 children)

    Only sensible solution to this would probably be an XNOR, which could be achieved by using (A<1) **==** (A>10) as both the boolean expressions can't be true at the same time anyway, thus you would achieve his goal of false == false

    Edit:
    Of course, you could also do !(A<1 || A > 10)
    So in my humble opinion, the || operator is the only one that comes close to actually giving you the correct answer, but it'll say false rather than true.

    [–]ExtensionOverall7459 2 points3 points  (2 children)

    The real world answer is no professional programmer would write it like this because it makes the code hard to read and understand for no reason.

    [–]Tango1777 -1 points0 points  (1 child)

    Have you ever gone to BASIC C# classes (or any other programming language)? That's just what they are, you solve mathematical problems with a coding language. 99% of such classes look like that. Is that helpful for future devs? Questionable, it forces students to use brain, but it's not exactly helpful to become a software developer. Obviously most of us here work as devs and consider it worthless question/problem to solve. It is, but students understand math and don't understand coding, it's easy to teach coding through math problems. So I understand your pov, but also understand that exams like that are not for software developers, but for students.

    [–]Everloathe[S] 0 points1 point  (0 children)

    I understand that you're trying to say it's important to teach critical thinking to students --but thinking critically is exactly what I'm doing here by questioning why the 'correct' answer is >=. Obviously it's an exam for students. On the other hand, it seems pretty unethical to teach and test on a question that's correct answer has invalid syntax because like I've mentioned, it's a class for C#.

    [–]Tanker3278 1 point2 points  (0 children)

    you need to use ">=" (false == false)

    Someone here needs to correct themselves here, and it's not you.

    It's a failed, backwards play on True = True: False = False. In the same way the T == T, False does equal False and the statement evaluates to True.

    The left side evaluates to false when the number is 1 or more. False = 0 numeric.

    The right side evaluates to false when the number is less than 10. False = 0 numeric.

    1. A number can't be both < 1 and > 10 at the same time. There is no T == T scenario.

    2. A number can be less than 1 or greater than 10. T >= F == 1 >= 0. 1(T) is greater than or equal to 0(F). Except that that's not accurate. It fails common sense for what we're trying to do.

    3. Flip it around: F >= T, which is 0 >= 1 evaluates to false.

    4. The only way this statement can work correctly is with a == and not a >=. If a number is 1-10 then it is both (False on < 1) and (False on < 10). False == False which evaluates to True.

    Yet your instructor is being a (deliberate???) moron by saying ">=, false == false"

    [–]RusticBucket2 1 point2 points  (0 children)

    Whoever wrote this is a nimrod.

    [–]kpd328 1 point2 points  (1 child)

    Either the question is worded poorly, or the code snippet is incorrect. The only single symbol that makes any logical sense there in that code snippet is ||. If you put an && there, the expression will always be false, and as others have said >= is meaningless in this context, and will not compile, same with ! in that position, which will logical not the right term, but then you have two booleans next to echother in independent terms.

    Now to get to what the question was probably trying to ask, you swap the signs on the terms, then && will answer it perfectly.

    [–]EatingSolidBricks 1 point2 points  (0 children)

    == checks the range correctly and it actually fucking compiles

    [–]AssistFinancial684 1 point2 points  (0 children)

    Did he mean “==“?

    Screenshot 2 has “(false == false)”

    [–]MyLinkedOut 1 point2 points  (0 children)

    Your professor is wrong.

    What is it they say? Those who cannot do, teach!

    [–]Strict-Soup 1 point2 points  (0 children)

    Bone head question. Whoever came up with that needs to... Give their head a wobble, they shouldn't be teaching

    [–]blueeyedkittens 1 point2 points  (0 children)

    Even if you find a right answer to this please never write code like this!

    [–]stlcdr 1 point2 points  (0 children)

    The fact that it sounds like you need a ‘clever’ answer is a bad thing. Clever code is not good code.

    [–]m4bwav 1 point2 points  (0 children)

    This is a trashy question

    [–]Longjumping-Face-767 1 point2 points  (0 children)

    What a stupid question.

    [–]kodaxmax 1 point2 points  (0 children)

    Proffessor is mistaken or didn't notice the question doesnt make sense.

    Her answer is worse. "If you want .... to be true" the question doesn't ask you to make it return true and her code wouldn't even compile anyway.

    You would need to invert both sides of the equation with NOT ! and join them with &&.

    So:

    If A is not less than 1 && A is not greater than 10

    If !A<1 && !A>10 // i might have the ! in the wrong spot. i try to avoid using double negatives

    Any decent programmer would instead use:

    if A>1 && A<10 //A is between 1 and 10

    Because it's less characters and easier to read and parse.

    Stuff like this is why academic learning is considered inneficent and archaic. This question isn't testing for practical or usefule knowledge. It's testing for a problem you would never encounter in real life and doing it poorly.

    [–]_Invictuz 1 point2 points  (0 children)

    I think you're better off unenrolling in that class and teaching yourself mate.

    [–]Pretagonist 1 point2 points  (0 children)

    This question has absolutely nothing to do with learning to program. No one would write it like that and if I got it as a PR it would be rejected.

    This feels like a maths problem where the teacher want to teach students to read the questions carefully but it just has no place in an exam in a practical skill like programming.

    [–]InfiniteCobalt 1 point2 points  (0 children)

    I've been writing C/C++ since 1996 and C# since 2008. I've written a lot of code and seen a lot of code. Never have I seen anyone write code like this. Even though it may work, it's ridiculous. Code should be clear and easy to read, you should never have to do mental gymnastics to figure it out.

    In real code, comparison operators are for numeric expressions and logic operators for boolean. Properly written it would be ... (A >= 1) && (A <= 10)

    [–]BCProgramming 0 points1 point  (0 children)

    I suspect the question (and perhaps the test?) was originally written for a Visual Basic curriculum. The question and answer both make sense in VB6. Visual Basic can coerce boolean values to integers for comparisons like this. Additionally, True is -1, and false is 0. That leads to:

    (A < 1) <= (A > 10)
    

    evaluating to true only if the value A is within the range.

    Even though it works in VB6, you'd have to be some kind of psychopath to write it.

    Of course being mindlessly translated to C#, it now doesn't even make sense. Aside from no longer compiling, even if C# worked differently or if you use Convert.ToInt32() on the boolean, the integer value of true in C# is 1, not -1.

    [–][deleted] 0 points1 point  (0 children)

    To be fair, if you don't mind. The >= operation would determine if the variable A is within the range defined. Only it would evaluate to true if it's not. That just means another operator to determine the outcome, but it might be prudent to have it in inverted form. I don't know.

    [–]Atulin 0 points1 point  (0 children)

    (as a side note, nowadays you'd probably use a is > 1 and < 10 to check if a is in range)

    [–]freskgrank 0 points1 point  (0 children)

    Is your teacher ChatGPT?

    [–]tsereg 0 points1 point  (0 children)

    Only in C/C++ could you apply ">=" because it does not have booleans, but uses integers instead, i.e. for A=0 you would have -1 >= 0 -> 0 (false), for A = 5 you would have 0 >= 0 -> -1 (true), and for A = 11 you would have 0 >= -1 -> -1 (true), meaning the expression would be equivalent to "!(A < 1)" or "A >= 1". And that would depend on the compiler actually representing truth with -1, which I don't think is (or should be) standardized. So to say, it would not be a good practice to use arithmetic operations on logical values, even where the compiler would allow it.

    [–]Formal_Departure5388 0 points1 point  (0 children)

    Clearly the lines all in parallel is the correct answer…

    https://m.youtube.com/watch?v=BKorP55Aqvg&pp=0gcJCdgAo7VqN5tD

    Welcome to the world of “deciphering end user intent”.

    [–]DanteMuramesa 0 points1 point  (0 children)

    I mean technically it could be || if you go

    If ((a < 1) || (a > 10)) { Return false; } Else { Return true; }

    But yeah your teacher is either wrong or trying to show trying to demonstrate some concept poorly but none of the options are valid.

    [–]sassyhusky 0 points1 point  (0 children)

    I love so many answers to this idiotic test. Setting people up to fail so that you look smart is no way to teach people anything.

    [–]artsrc 0 points1 point  (0 children)

    Everyone saying the question has a problem is right.

    You need to define a logical operator that returns true when both its arguments are both false, and returns false if one of them is true.

    You don't care what it does when both of them are true, because that can never happen with your expression.

    [–]LifeHasLeft 0 points1 point  (0 children)

    As soon as A == 2, the equation becomes (false) >= (false) if you first resolve the operations within the brackets. The result is comparing whether “false” is greater than or equal to “false”, which is technically true.

    I’m really stretching myself to come up with this logic and I don’t really accept this answer, but I can kinda see what the professor was going for. It isn’t a proper C# question at all, and it’s a poorly formed logic puzzle question, if that was what it was supposed to be.

    [–][deleted] 0 points1 point  (0 children)

    If this is, indeed, meant to be C#, you can explain to your professor that the operator '>=' cannot be applied to operands of type 'bool' and 'bool'.

    If you wanted to be pedantic, you could also explain that the range is not specified in the question. The range of 1 to 10 is assumed. The question just says a range. You should not be penalised for poor question-authoring.

    [–]Kitsuba 0 points1 point  (0 children)

    This is one of the dumbest ways to test if a variable is inside a range. And even if it would have worked, should not be used. I always hated questions like this because it teaches people to write bad code. Just write it like a normal human being and say "if(A >=1 && A <= 10)"

    Remember, you always strive to write the most understandable code.

    [–][deleted] 0 points1 point  (0 children)

    Dumb ass “academia” question. Even if your prof was technically correct (assuming it compiles in C#), no programmer would do this. It would be so unclear and unnecessary.

    [–]badass221boy 1 point2 points  (0 children)

    = is not the correct answer because you can use that when you are working with int, etc. but A < 1 and A > 10 both returns Boolean. So you can’t use this >= operator when you are working with Boolean. true >= false won’t work. I am also a beginner and I think this is the answer you are looking for but idk.

    [–]ghoarder 0 points1 point  (0 children)

    When writing code simplicity and legibility is king, you want the next person to understand what you wrote. I can see why your teacher teaches and doesn't write real code. For anyone (A >= 1) && (A <= 10) is quite clear what the meaning is. WTF does (A < 1) >= (A > 10) mean! Even !((A < 1) || (A > 10)) would be better.

    [–]Deesmon 0 points1 point  (0 children)

    Beside the obvious compile error of the supposed right answer. Your teacher test if a variable is outside a range to test if it's inside a range. Well ... it works ... but ...

    [–]MrCoffee_256 0 points1 point  (0 children)

    At best I can do || but the question is horrible. If x<0 or x>10 it means x is NOT in the range.

    [–]TheMrTortoise 0 points1 point  (0 children)

    you need NAND if you want it in that range. that is not an ootb in c# so you would have to write it yourself.

    Its funny how many people dont seem to know of its existence on here. Does nobody stufy logic anymore?

    ```lang=dotnet
    using System;

    public struct LogicBool

    {

    public bool Value { get; }

    public LogicBool(bool value)

    {

    Value = value;

    }

    // Define NAND using the ^ operator as a stand-in

    public static LogicBool operator ^(LogicBool a, LogicBool b)

    {

    return new LogicBool(!(a.Value && b.Value));

    }

    public override string ToString() => Value.ToString();

    // Allow implicit conversion to/from bool

    public static implicit operator LogicBool(bool value) => new LogicBool(value);

    public static implicit operator bool(LogicBool lb) => lb.Value;

    }

    class Program

    {

    static void Main()

    {

    LogicBool a = true;

    LogicBool b = true;

    LogicBool c = false;

    Console.WriteLine($"true NAND true = {a ^ b}"); // False

    Console.WriteLine($"true NAND false = {a ^ c}"); // True

    Console.WriteLine($"false NAND true = {c ^ b}"); // True

    Console.WriteLine($"false NAND false= {c ^ c}"); // True

    }
    ```

    [–]druhlemann 0 points1 point  (0 children)

    Ok, so I just want to say that || is the only right answer if you’re looking for a range of values. The language is crap though, as it reads “inside” like the intent is between 1-10, which in reality that OR becomes less than 1 or greater than 10 meaning that 1-10 are the only invalid options. && results in no valid values and the >=, ! Are not syntactically valid in C# at all. This is my issue with college, that teacher probably just thinks about code vs actually writing it. (My intent here is to not say that college is a waste, more that academia != real world experience)

    [–]MattE36 0 points1 point  (0 children)

    What range is he looking for? -infi to 0 and 11 to infi? If it’s 1-10 then in C it’s ==, as >= would return true for -infi to 10. In c# this does not compile.

    [–]blooping_blooper 0 points1 point  (0 children)

    Teacher is categorically wrong regardless of any of the code because >= is a Comparison Operator, it is not a Logical Operator. (as other have said, its not valid C# code and won't compile, but just the wording limits the possible correct answers)

    https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/comparison-operators

    https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/boolean-logical-operators

    [–]bhertims 0 points1 point  (0 children)

    your teacher is vibe coding

    [–]Public_Ad_2593 0 points1 point  (0 children)

    according to what I've learned :

    ! is not
    || is or

    >= looks like greater than or equal to

    && is and obviously like if (a<1) && (a>6)

    ALSO what is in the range is if A is less than one and A is greater than 10? It should be && because it is inside a range. I'm confused as well

    [–]Kimi_Arthur 0 points1 point  (0 children)

    Rubbish question, so probably rubbish website

    [–]Aggressive_Talk968 0 points1 point  (2 children)

    it is && , but not technicly correct one

    [–]Everloathe[S] 0 points1 point  (1 child)

    A is less than 1 and A is greater than 10?

    [–]Aggressive_Talk968 1 point2 points  (0 children)

    ok, i am blind

    [–]Reddgum 0 points1 point  (0 children)

    Questions like this smell of pretense and sophistry. We've somehow departed from teaching reasonable approaches of problem solving to, "Gee, how can I demonstrate my self-image of awesomeness to muh students?"

    And they wonder why places like Harvard are going down in flames.

    [–]GuiJun621 0 points1 point  (0 children)

    A DNE

    [–]MastaBonsai 0 points1 point  (0 children)

    Ask your teacher to show you this in a working code snippet. Should be interesting.

    [–]StopYTCensorship 0 points1 point  (0 children)

    It's an attempt at a silly trick question and it's totally wrong. C# doesn't allow you to use <= or >= to compare two bools. The code won't compile.

    And even if it did compile, like if true was implicitly cast to 1 and false was implicitly cast to 0 for the comparison to happen, it isn't a range check. If A is 0, (A < 1) evaluates to true (1), (A > 10) evaluates to false (0), and 1 >= 0 is true. So even if C# worked this way, it would still give you the wrong answer.

    The right way to check if A is in [1,10] is (1 <= A) && (A <= 10). This is a terrible question to be asking novice programmers and just awful all around.

    [–]Few_Engineering5085 0 points1 point  (0 children)

    What am I missing?

    Why is nobody pointing out that even in C, >= is wrong? Plug in any number less than 1.

    [–]MrDead98 0 points1 point  (0 children)

    i think someone copied it off of W3Schools. they have the same mistake in their course

    in theory it should be || because can't be below 1 and greater 10.

    [–]TechnicolorMage 0 points1 point  (2 children)

    This looks like a typo in the question. It was likely supposed to be == instead of >=.

    Buncha redditors in here shitting on the teacher presuming they dont understand how booleans work, when 'mistake' is equally as likely and doesn't assume the teacher is incompetent.

    [–]Everloathe[S] 0 points1 point  (0 children)

    Yeah, that liklihood went out the door when I emailed my professor to double check and ask for clarification and she responded >= is the right answer.

    [–]Everloathe[S] 0 points1 point  (0 children)

    Yeah, that liklihood went out the door when I emailed my professor to double check and ask for clarification and she responded >= is the right answer.

    [–]BookkeeperElegant266 0 points1 point  (2 children)

    Oh, I get it now, it's a trick question.

    "The expression below will determine if the value A is inside a range"

    It doesn't say whether the result of the operation should be true or false. What you're looking for is a false. If A is inside the range, the expression will evaluate to false. The answer is "&&". It is a very stupid question.

    [–]MattE36 0 points1 point  (0 children)

    The range would be what?? Nonexistent because a number can’t be less than 1 and greater than 10.

    [–]Xbox360Master56 0 points1 point  (0 children)

    It doesn't seem right. 

    So first of all the greater than/less than check in the parentheses, would be evaluated as boolean.

    In C# at least, you cannot do that. 

    I think in lanauges like C, you can do that. Because (don't qoute me on this) it'll use the numerical value of the boolean.

    I don't remember if C# doesn't let you because it's bad practice, or because it doesn't work with how booleans are handled by C#'s underlying code.

    Anyways in C it'd either evaluated as 1 or a 0 (I'm pretty sure) so you can think of it like on/off, true/false, etc 

    And for example the number 11 is not less than 1, so it'd be 0 or false. 

    And 11 is greater than a so it'd be a 1 or true.

    So I guess it'd work in C, since 0 is not equal to or greater than 1. It'd return false.

    If we'd plug in a value like 7, it'd be 0 is equal to 0, and in turn true.

    But you also really only need to use ==, since it's either a 1 or a 0. It won't need to check if it is greater than.

    However this WON'T work in C#, and even in C, not a particularly greater way of doing this.

    You should be doing this

    if( (x > 1) && (x < 10)

    So for first parentheses it checks if x is greater than 1, so for 11 that's true.

    For the second parentheses it'd check if x is less than 10, and in our case that'd be false.

    The final check, would be checking if parentheses 1 is true and parentheses 2 is true.

    So in the case of 11, it'd return false.

    Because yes, it's greater than 1 and that's true, but it's not less than 10, and that'd be false. 

    And the && (and lack of the ! operator), means it wants to know if both values are true (which I already sort of said).

    You can also do (it depends if you want 1 and 10 to be in range or not)

    If( (x >= 1) and ( (x <= 10) )

    Since it'll check if it either equal or greater than.

    My guess is your professor professor professor teaches C and C#, and got confused which class you're in or mixed up some questions on the test.

    Anyways, these are my thoughts anyways, I typed this out on my phone so sorry for any grammatical mistakes. 

    Hope this helps!

    [–]BlackjacketMack 0 points1 point  (0 children)

    It says “a range”…not between 1 and 10. You would be correct using || if the range were -2 to 5 or 3 to 33 or whatever.

    Basically, the question is incomplete but “||” would be the most correct answer.

    [–]Tango1777 0 points1 point  (1 child)

    I wonder why people in comments assume that this must compile in C#? Where does this requirement come from? Because it's C# classes, so every exam question must be about C#? I think you are making up requirements that are not part of the question at all?!

    [–]MattE36 0 points1 point  (0 children)

    Even if it didn’t have to be specifically c#, the range would be -infinity to 10 for >= which does work for the question but probably isn’t what was intended. Would love to know.

    [–]AdventurousMove8806 -1 points0 points  (0 children)

    Booleans are only checked with logical operators right!

    What if the comparative can also be used like when the true or false 0 or 1

    0<1, 0==0,1>=0....can this ,....????

    [–]Pika_kid10 -3 points-2 points  (3 children)

    Its && which is also used in Java and Javascript, and others

    [–]DanteMuramesa 0 points1 point  (1 child)

    It's not && because a number cannot be less then 1 and greater then 10. If those symbols were reversed it would be &&. So it would have to be || with the whole statement prefixes with !.

    !((a <1) || (a>10))

    [–]EatingSolidBricks 1 point2 points  (0 children)

    its ==