Why am i getting no output while i think it should come "four" Or where am i wrong help 🙏 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why am i getting no output while i think it should come "four" Or where am i wrong help 🙏

int x=4; switch(x) {case 1: Console.WriteLine("one"); break; case 2: Console.WriteLine("two"); break; case 3: Console.WriteLine("four"); break; } // No output (but why?) Shouldnt it be four or????

15th Aug 2019, 12:45 AM
DataStream Cowboy
DataStream Cowboy - avatar
1 Answer
+ 2
x is equal to 4 it goes throw the cases: 1, 2, 3 none of which equal 4 ... so no there is no output add a default case or more cases 🤷‍♂️
15th Aug 2019, 1:28 AM
Anton Böhler
Anton Böhler - avatar