How to assign two conditions to an if statement? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to assign two conditions to an if statement?

hello, I am wondering if there is a away to assign two conditions to a single if statement. for example: I want something like this int test_score = 100; if (test_score == 100) Console.WriteLine("Perfect"); if (test_score >= 90 , test_score < 100); Console.WriteLine("Grade A"); Thanks in advance for any help

19th Jan 2017, 2:17 AM
Code4Phun
Code4Phun - avatar
3 Answers
+ 6
Yes, there is. Use the operator && (AND) to check if both conditions are true. Ex: if (test_score >= 90 && test_score < 100) Console.WriteLine("Grade A");
19th Jan 2017, 3:02 AM
Tamra
Tamra - avatar
+ 3
use && or || int test_score = 100; if (test_score == 100) Console.WriteLine("Perfect"); if (test_score >= 90 && test_score < 100); Console.WriteLine("Grade A");
19th Jan 2017, 3:00 AM
lowshuen
0
thank you so much!
19th Jan 2017, 3:01 AM
Code4Phun
Code4Phun - avatar