mslearn-csharp-programming

The following exercises are designed to help you practice the skills you’ve learned in the Get Started with C# learning path on Microsoft Learn. Each exercise is self-contained and can be completed independently, but they are best used in conjunction with the corresponding modules on Microsoft Learn.

Exercises


Create a personalized greeting

Level: 100 | Duration: 15 minutes

Write a C# program that uses Console.WriteLine(), Console.ReadLine(), and string interpolation to display a personalized greeting message.


Challenge: Interact with the user

Level: 100 | Duration: 15 minutes

Write a C# program that combines Console.Write(), Console.ReadLine(), and string interpolation to collect multiple pieces of information from the user and display a personalized message.


Work with literals and variables

Level: 100 | Duration: 15 minutes

Write a C# program that declares variables using explicit types and the var keyword, assigns literal values to them, and displays the values.


Build a tip calculator

Level: 100 | Duration: 20 minutes

Write a C# program that stores bill values as variables, performs arithmetic to calculate a tip and total, and accepts amounts as user input using type conversion.


Challenge: Convert Fahrenheit to Celsius

Level: 100 | Duration: 15 minutes

Write a C# program that stores a Fahrenheit temperature, converts it to Celsius using decimal arithmetic, and displays a formatted result.


Build a dice game

Level: 100 | Duration: 20 minutes

Write a C# program that simulates rolling dice, uses if, else if, and else to award a prize, and uses logical operators to detect doubles and triples.


Challenge: Display a subscription renewal message

Level: 100 | Duration: 20 minutes

Write a C# program that uses if, else if, and else to display a subscription renewal message and discount based on a randomly generated number of days until expiration.


Create a Guess the Number game

Level: 100 | Duration: 25 minutes

Write a C# program that uses a while loop, conditional logic, and break to run an interactive Guess the Number game.


Create a Top 5 leaderboard

Level: 100 | Duration: 25 minutes

*Write a C# program that logs game scores in a List and builds a fixed-size Top 5 leaderboard array.*


Create a billing calculator

Level: 100 | Duration: 25 minutes

Write a C# program that organizes tax and total calculations into a Billing namespace, using methods with default parameters, named arguments, and return values.


Create a log file viewer

Level: 100 | Duration: 25 minutes

Write a C# program that appends event entries to a log file, then reads them back line by line with a StreamReader.


Note: While you can complete these exercises on their own, they’re designed to complement modules on Microsoft Learn; in which you’ll find a deeper dive into some of the underlying concepts on which these exercises are based.