30 C# Basic Exercises for Intermediate with Solutions
Master intermediate C# skills with our comprehensive list of top 30 exercises. Dive into coding challenges that improve your understanding and proficiency in C#, setting a solid foundation for advanced challenges. Start your journey to C# mastery today!
Learning Objectives:
Master intermediate C# skills with our comprehensive list of top 30 exercises. Dive into coding challenges that improve your understanding and proficiency in C#, setting a solid foundation for advanced challenges. Start your journey to C# mastery today!
Exercise Instructions:
- Start with the first exercise and attempt to solve it before checking the hint or solution.
- Ensure you understand the logic behind each solution, as this will help you in more complex problems.
- Use these exercises to reinforce your learning and identify areas that may require further study.
1. Write a program to calculate the sum of all prime numbers between two hardcoded numbers.
Required Input:
Range: 10 to 30
Expected Output:
Sum of Prime Numbers: 112
Code In C#
Run Code?
Click Run Button to view compiled output
2. Create a program to check if a given string is an anagram of another hardcoded string.
Required Input:
Strings: "listen" and "silent"
Expected Output:
Is Anagram: True
Code In C#
Run Code?
Click Run Button to view compiled output
3. Write a program to find the second smallest number in a hardcoded array.
Required Input:
Array: [4, 2, 9, 1, 5]
Expected Output:
Second Smallest: 2
Code In C#
Run Code?
Click Run Button to view compiled output
4. Create a program to remove all vowels from a hardcoded string and print the result.
Required Input:
String: "programming"
Expected Output:
String without Vowels: prgrmmng
Code In C#
Run Code?
Click Run Button to view compiled output
5. Write a program to count the frequency of each element in a hardcoded array.
Required Input:
Array: [1, 2, 2, 3, 1, 4]
Expected Output:
Frequencies:
1: 2
2: 2
3: 1
4: 1
Code In C#
Run Code?
Click Run Button to view compiled output
6. Create a program to generate all permutations of a hardcoded string.
Required Input:
String: "abc"
Expected Output:
Permutations:
abc
acb
bac
bca
cba
cab
Code In C#
Run Code?
Click Run Button to view compiled output
7. Write a program to check if a hardcoded 2D array is symmetric along its diagonal.
Required Input:
Matrix:
[ [1, 2, 3],
[2, 4, 5],
[3, 5, 6] ]
Expected Output:
Is Symmetric: True
Code In C#
Run Code?
Click Run Button to view compiled output
8. Create a program to sort a hardcoded array in descending order without using built-in methods.
Required Input:
Array: [5, 2, 9, 1, 7]
Expected Output:
Sorted Array: 9, 7, 5, 2, 1
Code In C#
Run Code?
Click Run Button to view compiled output
9. Write a program to calculate the sum of digits of all numbers in a hardcoded array.
Required Input:
Array: [123, 45, 67]
Expected Output:
Sum of Digits: 28
Code In C#
Run Code?
Click Run Button to view compiled output
10. Create a program to calculate the product of all odd numbers in a hardcoded array.
Required Input:
Array: [1, 2, 3, 4, 5]
Expected Output:
Product of Odd Numbers: 15
Code In C#
Run Code?
Click Run Button to view compiled output