0
Multiple condition in cs
Is there a way to add multiple condition to an answer E.g : if (condition 1 and condition 2) {Execute this statement;} Or maybe there's a way to add range E.g : if (x is >2 & < 6 ) [i.e 3,4 or 5. Is true] {Execute this statement;} Please if you have any idea on how to implement the this in C# comment below
10 Respostas
+ 6
Have you gotten to this part of the tutorial yet?
https://www.sololearn.com/learn/CSharp/2598/?ref=app
+ 3
Share a link to your code bit so we can sort it out ...
https://www.sololearn.com/post/75089/?ref=app
+ 3
Ipang it's alright now thanks đđđ
+ 2
U can use nested if instead of writing More condition in one if statement
+ 2
So I think I've got it my mistake was using (x > 2 && < 6) instead of (x > 2 && x < 6) . Here's my code feel free to like https://code.sololearn.com/c9QXsPnPimfE/?ref=app
+ 2
int x = Convert.ToInt32(Console.ReadLine());
string a =
(x < 0) ? "unborn" :
(x <= 4) ? "toddler" :
(x <= 13) ? "child" :
(x <= 17) ? "teenager" :
(x < 49) ? "adult" :
(x < 70) ? "elderly" :
(x <= 90) ? "aged" :
"You're really old, But how the hell are you still alive ;-)" ;
Console.WriteLine(a);
// Keep learning & happy coding :D
+ 1
You mean something like this in the if declaration?
If (x >= 2 && x < 6)
{ // code goes here }
Or more conditions?
+ 1
Ipang yes but it's not working in my code I'll recheck to be sure
+ 1
Muhammad too many ifs nearly made me mad. đ but it's fixed now
0
Terel yes