C# Basic Algorithm Exercises
1. Write a program to get 3 values from user and print sum of its square value.
2. Write a program to get 3 values from user and print sum of its cube value.
3. Write a program to get required values from user to calculate length of open belt drive and print length.
4. Write a program to get required values from user to calculate length of cross belt drive and Print length.
5. Write a program to get required values to calculate Torque required to raise load and print torque value in console.
6. Write a program to swap 2 numbers.
7. Write a program to convert degree to radian.
8. Write a program to convert radian to degree.
9. Write a program to convert kelvin to Fahrenheit.
10. Write a program to convert celsius to Fahrenheit.
C# Conditional Statement Exercises
11. Write a program to get two integers and check whether they are equal or not.
12. Write a program to check whether a given number is positive or negative.
13. Write a program to check whether a given year is a leap year or not.
14. Write a program to find the largest of three numbers.
15. Write a program to read the age of a candidate and determine whether it is eligible for casting his/her own vote.
16. Write a program to check whether entered number is in range 20 to 50.
17. Write a program to check which number nearest to the value 100 among two given integers.
18. Write a program to check if two given non-negative integers have the same last digit.
19. Write a program to find the eligibility of admission for a professional course based on the following criteria.
Marks in Maths >=85
Marks in Phy >=75
Marks in Chem>=70
Total in all three subject >=230
20. Write a program to read temperature in centigrade and display a suitable message according to temperature state below.
Temp < 0 then Freezing weather
Temp 0-10 then Very Cold weather
Temp 10-20 then Cold weather
Temp 20-30 then Normal in Temp
Temp 30-40 then Its Hot
Temp >=40 then Its Very Hot
21. Write a program to read any Month Number in integer and display Month name in the word.
C# Loop and Nested Loop Exercises
22. Write a program to display the first 10 natural numbers using while, for and do while loops.
23. Write a program to display the first 10 even numbers using while, for and do while loops.
24. Write a program to display the first 10 odd numbers using while, for and do while loops.
25. Write a program to get integer values print its factorial value.
26. Write a program to print CodersCapsule text for 5 times.
27. Write a program to get Base and Power value and print its Exponent.
28. Write a program to find whether entered number is prime number or not.
29. Write a program to find whether entered number is armstrong number or not.
30. Write a program to find whether entered number is strong number or not.
31. Write a program to reverse digits.
For example, if the input is 12345, the output should be 54321.
32. Write a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop should ask the user whether he or she wishes to perform the operation again. If so, the loop should repeat; otherwise it should terminate.
33. Write a program which takes a random number and asks the user to guess what the number is. If the user's guess is higher than the random number, the program should display "Too high, try again." If the user's guess is lower than the random number, the program should display "Too low, try again." The program should use a loop that repeats until the user correctly guesses the random number.
34. Write a program to calculate HCF of Two given number.
35. Write a program to calculate LCM of Two given number.
36. Write a program to print first 10 even numbers.
37. Write a program to print first 10 odd numbers.
38. Write a program to print first 10 prime numbers.
39. Write a program to find the Armstrong number from 1 to 1000.
40. Write a program to print right angle triangle shape using *
41. Write a program to print Triangle shape using *
42. Write a program to print Inverse triangle shape using *
43. Write a program to print diamond shape using *
44. Write a program to print Triangle shape using numbers
        1
      222
    33333
  4444444
555555555
45. Write a program to print Triangle shape using numbers
        1
      212
    32123
  4321234
543212345
46. Write a program to print Triangle shape using alphabets
        A
      ABA
    ABCBA
  ABCDCBA
ABCDEDCBA
47. Write a program to input any number and print it in words.
Input any number: 8309
Output : Eight Three Zero Nine
C# Array Exercises
48. Take 2 integer arrays with same number of elements. Finds its sum and store it in another integer array.
49. Take a string array , print all elements in reverse order.
50. Take a string array , print all elements in reverse order.
51. Take an integer array with random elements, sort it in ascending order.
52. Take an integer array with random elements, sort it in descending order.
53. Take an integer array find its maximum and minimum value.
54. Write a program to find the common elements between two string arrays.
55. Write a program to find the second largest element in an integer array.
56. Write a program to find the second smallest element in an integer array.
57. Write a program to find the sum of all elements in first integer array equal to sum of all elements in second integer array.
58. Write a program to print prime numbers in an integer array.
59. Write a program to separate even and odd numbers of a given array of integers. Put all even numbers first, and then odd numbers.
60. Take char array with random special characters, find how many times each character is duplicated.
C# String Handling Exercises
61. Take a string value print how many characters are there(Don't use in-built length() method).
62. Take a string append "@coderscapsule.com" in the end.
63. Write a program to reverse characters of a string.
64. Write a program to replace all vowels of a string using '$'.
65. Write a program to check if a given string is a Palindrome or not.
66. Write a program to find a word in a given string which has the highest number of characters.
67. Write a program to find a word in a given string which has the highest number of repeated letters.
68. Write a program to print every character of a string entered by user in a new line using loop.
69. Take a string array and print each string with its highest number of repeated letters.
70. Take a string array and check how many elements ends with 'a' and print all those.
C# Method Exercises (OOPs)
71. Write a method to find the smallest number among three numbers.
72. Write a method to find the largest number among three numbers.
73. Write a method to display the middle character of a string.
74. Write a method to count all vowels in a string.
75. Write a method to check whether a year (integer) entered by the user is a leap year or not.
76. Write a method to check whether a string is a valid password.
Password rules:
A password must have at least ten characters.
A password consists of only letters and digits.
A password must contain at least two digits.
77. Write a method that accept three integers and check whether they are consecutive or not. Return true or false.
78. Write a method to check whether every digit of a given integer is even or not. Return true if its even, otherwise return false.
79. Write a method that checks whether all the characters in a given string are vowels (a, e,i,o,u) or not. Return true if each character of the string is a vowel, otherwise return false.
80. A positive integer is called a palindrome if it reads forward and backward in the same way. For example, the numbers 5, 121, 3443, and 123454321 are palindromes. Write a method that takes as input a positive integer and returns true if the number is a palindrome; otherwise, it returns false. Also write a program to test your method.
C# Class with constructor Exercises (OOPs)
81. Print the average of three numbers entered by user by creating a class named 'Average' having a method to calculate and print the average.
82. Print the sum, difference and product of two numbers by creating a class named 'Calculations' with separate methods for each operation.
83. Write a program by creating an 'Employee' class having the following constructor and methods and print the final salary.
1 - 'Employee()' which is a constructor that takes the salary, number of hours of work per day of employee as parameter
2 - 'AddSal()' which adds $10 to salary of the employee if it is less than $500.
3 - 'AddWork()' which adds $5 to salary of employee if the number of hours of work perday is more than 6 hours
84. Create a class called 'Matrix' containing constructor that initializes the number of rows and number of columns of a new Matrix object. The Matrix class has the following information:
1) number of rows of matrix
2) number of columns of matrix
3) elements of matrix in the form of 2D array
The Matrix class has methods for each of the following:
1 - get the number of rows
2 - get the number of columns
3 - set the elements of the matrix at given position (i,j)
4 - adding two matrices. If the matrices are not addable, "Matrices cannot be added" will be displayed.
5 - multiplying the two matrices
85. Write a program that has variables to store Car data like; CarModel, CarName, CarPrice and CarOwner. The program should include constructor to assign user defined values to the above mentioned variable and a display function to show the values. Now In main method declare three Carobjects and displays the data of all three.
86. Write a program to print the area and perimeter of a triangle having sides of length = 3 and height = 5 by creating a class named 'Triangle' without any parameter in its constructor.
87. Create a class named Pizza that stores information about single pizza. It should contain the following:
1) Private variables to store the size of the pizza (either small, medium,or large), the number of cheese toppings, the number of pepperoni toppings, and the number of ham toppings.
2) Constructor(s) that set all of the variables.
3) A public method named calcCost() that returns a double that is the cost of the pizza. Pizza cost is determined by:
Small: $10 + $2 per topping
Medium: $12 + $2 per topping
Large: $14 + $2 per topping
4) public method named getDescription() that returns a String containing the pizza size, quantity of each topping
Write test code to create several pizzas and output their descriptions. For example, a large pizza with one cheese, one pepperoni and two ham toppings should cost a total of $22. Now Create a Pizza Order class that allows up to three pizzas to be saved in an order.Each pizza saved should be a Pizza object.
88. Create a class called BankAccount which represents a bank account, having as attributes: accountNumber (numeric type), name (name of the account owner as string type), balance. Create a constructor with parameters: accountNumber, name, balance. Create a Deposit() method which manages the deposit actions. Create a Withdrawal() method which manages withdrawals actions. Create an bankFees() method to apply the bank fees with a percentage of 5% of the balance account. Create a display() method to display account details.
C# Abstract Class and Interface Exercises (OOPs)
89. Create an abstract class 'Parent' with a method 'message'. It has two subclasses each having a method with the same name 'message' that prints "This is first subclass" and "This is second subclass" respectively. Call the methods 'message' by creating an object for each subclass.
90. Create an abstract class 'Bank' with an abstract method 'getBalance'. $100, $150 and $200 are deposited in banks A, B and C respectively. 'BankA', 'BankB' and 'BankC' are subclasses of class 'Bank', each having a method named 'getBalance'. Call this method by creating an object of each of the three classes.
91. Create an abstract class 'Animals' with two abstract methods 'cats' and 'dogs'. Now create a class 'Cats' with a method 'cats' which prints "Cats meow" and a class 'Dogs' with a method 'dogs' which prints "Dogs bark", both inheriting the class 'Animals'. Now create an object for each of the subclasses and call their respective methods.
92. Create an interface 'Shape' with three methods namely 'RectangleArea' taking two parameters, 'SquareArea' and 'CircleArea' taking one parameter each. The parameters of 'RectangleArea' are its length and width, that of 'SquareArea' is its side and that of 'CircleArea' is its radius. Now create another class 'Area' containing all the three methods 'RectangleArea', 'SquareArea' and 'CircleArea' for printing the area of rectangle, square and circle respectively. Create an object of class 'Area' and call all the three methods.
C# Ref, Out Parameter Exercises (OOPs)
93. Write a function void Swap2Numbers(ref int, ref int) which receives 2 integer, and swap those 2 int values.
94. Write a function void GreatestAndSmallest(ref int,ref int,ref int) which receives 3 integers, find out the greatest and the smallest among three numbers
95. Write a function void PersonalDetails(ref string name,ref int age,ref string hometown, out message) Where message should be "Welcome" and print in following order
OUTPUT: -message- –name-, whose age is –age-, he/she belongs to –hometown-
96. Write a function void simpleMath(double number, ref double square, out double cube). Here square should return square value of number. cube should return cube value of number.
C# DateTime Exercises
97. Write a program to print Traingle shape using * and make it available only for next 48 hours.
98. Write a program to find cube value and make it available only for next 1 week.
99. Write a program to check sum of today date is even or odd number.
EG : 16/11/2022 - 16+11+2022 = 2049 (Odd number)
100. Write a program to check whether year(5 years from now) is leap year or not.