Master C# programming through hands-on coding challenges. Write real code, get instant feedback, and build practical skills for .NET development.
Write actual C# code to solve each challenge. Your code is validated for correctness.
string name = "John Smith";. The string keyword is an alias for System.String.int type is a 32-bit signed integer ranging from -2,147,483,648 to 2,147,483,647. For larger numbers, use long (64-bit).double type provides 15-17 digits of precision. For financial calculations, use decimal instead for exact precision.true or false to indicate student status. Note: C# booleans use lowercase (true/false), unlike some other languages.Console.WriteLine() to print each variable with a descriptive label. You can use string interpolation (recommended): Console.WriteLine($"Name: {name}"); or concatenation: Console.WriteLine("Name: " + name);;var for type inference$"" is cleaner than concatenationName: John Smith
Age: 25
Height: 1.75
Is Student: True
string name = "John";int age = 25;double height = 1.75;bool isStudent = true;Console.WriteLine($"Age: {age}");Console.WriteLine("Age: " + age);Review feedback below
char uses single quotes: char grade = 'A';. Remember: single quotes for char, double quotes for string.if (score >= 90) → Grade A (Excellent - top performers)else if (score >= 80) → Grade B (Good - above average)else if (score >= 70) → Grade C (Average - meets expectations)else if (score >= 60) → Grade D (Below Average - needs improvement)else → Grade F (Failing - below 60)?: to determine and print "PASSED" or "FAILED".>= > < <= == !=string status = score >= 60 ? "PASSED" : "FAILED";Score: 85
Grade: B
Status: PASSED
if (score >= 90) { grade = 'A'; }else if (score >= 80) { grade = 'B'; }>= > < <= == !='A' not "A"string status = score >= 60 ? "PASSED" : "FAILED";Review feedback below
for (int i = 1; i <= 20; i++) { ... }int i = 1 - initialization (start at 1)i <= 20 - condition (continue while i is 20 or less)i++ - increment (add 1 to i after each iteration)% operator returns the remainder after division. If i % 3 == 0, then i divides evenly by 3 (no remainder), meaning i IS divisible by 3.9 % 3 = 0 (divisible), 10 % 3 = 1 (not divisible), 15 % 5 = 0 (divisible)foreach loops for collectionswhile and do-while loopsEnumerable.Range(1, 20)1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
for (int i = 1; i <= 20; i++) { }if (i % 3 == 0 && i % 5 == 0)15 % 3 == 0 is true (15 ÷ 3 = 5, no remainder)Console.WriteLine(i);i % 15 == 0 for FizzBuzz (15 = 3 × 5)Review feedback below