0% found this document useful (0 votes)
6 views25 pages

Basic Exercise

Uploaded by

ngoocmynn
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views25 pages

Basic Exercise

Uploaded by

ngoocmynn
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Print Hello and Name


Write a C# Sharp program to print Hello and your name in a separate line.
Expected Output :
Hello: Alexandra Abramov

2. Sum of Two Numbers

Write a C# Sharp program to print the sum of two numbers.

3. Divide Two Numbers

Write a C# Sharp program to print the result of dividing two numbers.

4. Specified Operations Results

Write a C# Sharp program to print the results of the specified operations.


Test data:

• -1 + 4 * 6
• ( 35+ 5 ) % 7

• 14 + -4 * 6 / 11

• 2 + 15 / 6 * 1 - 7 % 2

Expected Output:
23
5
12
3

5. Swap Two Numbers

Write a C# Sharp program to swap two numbers.


Test Data:
Input the First Number : 5
Input the Second Number : 6
Expected Output:
After Swapping :
First Number : 6
Second Number : 5

6. Multiply Three Numbers

1
Write a C# Sharp program to print the output of the multiplication of three numbers entered by the user.
Test Data:
Input the first number to multiply: 2
Input the second number to multiply: 3
Input the third number to multiply: 6
Expected Output:
2 x 3 x 6 = 36

7. Arithmetic Operations

Write a C# Sharp program to print on screen the output of adding, subtracting, multiplying and dividing
two numbers entered by the user.
Test Data:
Input the first number: 25
Input the second number: 4
Expected Output:
25 + 4 = 29
25 - 4 = 21
25 x 4 = 100
25 / 4 = 6
25 mod 4 = 1

8. Multiplication Table

Write a C# Sharp program that prints the multiplication table of a number as input.
Test Data:
Enter the number: 5
Expected Output:
5*0=0
5*1=5
5 * 2 = 10
5 * 3 = 15
....
5 * 10 = 50

9. Average of Four Numbers

Write a C# Sharp program that takes four numbers as input to calculate and print the average.
Test Data:
Enter the First number: 10
Enter the Second number: 15
Enter the third number: 20
Enter the four number: 30

2
Expected Output:
The average of 10 , 15 , 20 , 30 is: 18

10. Specified Formula with Three Numbers

Write a C# Sharp program that takes three numbers (x,y,z) as input and outputs (x+y).z and x.y + y.z.
Test Data:
Enter first number - 5
Enter second number - 6
Enter third number - 7

Expected Output:
Result of specified numbers 5, 6 and 7, (x+y).z is 77 and x.y + y.z is 72

11. Print Age Message

Write a C# Sharp program that takes an age (for example 20) as input and prints something like "You
look older than 20".
Test Data:
Enter your age - 25
Expected Output:
You look older than 25

12. Repeat Number in Rows

Write a C# program that takes a number as input and displays it four times in a row (separated by blank
spaces), and then four times in the next row, with no separation. You should do it twice: Use the
console. Write and use {0}.
Test Data:
Enter a digit: 25
Expected Output:
25 25 25 25
25252525
25 25 25 25
25252525

13. Rectangle Pattern with Number

Write a C# program that takes a number as input and displays a rectangle of 3 columns wide and 5 rows
tall using that digit.
Test Data:
Enter a number: 5
Expected Output:
555

3
55
55
55
555

14. Celsius to Kelvin and Fahrenheit

Write a C# program to convert Celsius degrees to Kelvin and Fahrenheit.


Test Data:
Enter the amount of celsius: 30
Expected Output:
Kelvin = 303
Fahrenheit = 86

15. Remove Character by Index

Write a C# program that removes a specified character from a non-empty string using the index of a
character.
Test Data:
w3resource
Sample Output:
wresource
w3resourc
3resource

16. Swap First and Last Characters

Write a C# program to create a new string from a given string where the first and last characters change
their positions.
Test Data:
w3resource
Python
Sample Output:
e3resourcw
nythoP
x

17. Add First Character to Front and Back

Write a C# program to create a string from a given string (length 1 or more) with the first character
added at the front and back.
Sample Output:
Input a string : The quick brown fox jumps over the lazy dog.

4
TThe quick brown fox jumps over the lazy dog.T

18. Check Positive and Negative Pair


Write a C# program to check a pair of integers and return true if one is negative and one is positive.
Sample Output:
Input first integer:
-5
Input second integer:
25
Check if one is negative and one is positive:
True

19. Sum or Triple Sum of Integers

Write a C# program to compute the sum of two given integers. If two values are the same, return the
triple of their sum.

20. Absolute Difference or Double It

Write a C# program to get the absolute value of the difference between two given numbers. Return
double the absolute value of the difference if the first number is greater than the second number.

21. Check for 20 or Sum Equals 20

Write a C# program to check the sum of the two given integers. Return true if one of the integers is 20
or if their sum is 20.

22. Check Within 20 of 100 or 200


Write a C# program to check if the given integer is within 20 of 100 or 200.
Sample Output:
Input an integer:
25
False

23. Convert String to Lowercase

Write a C# program to convert a given string into lowercase.


Sample Output:
write a c# sharp program to display the following pattern using the alphabet.

24. Find Longest Word in String

5
Write a C# program to find the longest word in a string.
Test Data: Write a C# Sharp Program to display the following pattern using the alphabet.
Sample Output:
following

25. Print Odd Numbers 1 to 99

Write a C# program to print odd numbers from 1 to 99. Prints one number per line.
Sample Output:
Odd numbers from 1 to 99. Prints one number per line.
1
3
5
7
9
...
95
97
99

26. Sum of First 500 Primes

Write a C# program to compute the sum of the first 500 prime numbers.
Sample Output:
Sum of the first 500 prime numbers:
824693

27. Sum of Digits in Integer


Write a C# program and compute the sum of an integer's digits.
Sample Output:
Input a number(integer): 12
Sum of the digits of the said integer: 3

28. Reverse Words in Sentence

Write a C# program to reverse the words of a sentence.


Sample Output:
Original String: Display the pattern like pyramid using the alphabet.
Reverse String: alphabet. the using pyramid like pattern the Display

29. File Size in Bytes

6
Write a C# program to find the size of a specified file in bytes.
Sample Output:
Size of a file: 31

30. Hexadecimal to Decimal

Write a C# program to convert a hexadecimal number to a decimal number.


Sample Output:
Hexadecimal number: 4B0
Convert to-
Decimal number: 1200

31. Multiply Two Arrays

Write a C# program to multiply the corresponding elements of two integer arrays.


Sample Output:
Array1: [1, 3, -5, 4]
Array2: [1, 4, -5, -2]
Multiply corresponding elements of two arrays:
1 12 25 -8

32. Four Copies of Last Four Characters


Write a C# program to create a string of four copies, taking the last four characters from a given string.
If the given string is less than 4, return the original one.
Sample Output:
Input a string : The quick brown fox jumps over the lazy dog.
[Link].

33. Check Multiple of 3 or 7

Write a C# program to check if a given positive number is a multiple of 3 or 7.


Sample Output:
Input first integer:
15
True

34. Check String Starts with Word

Write a C# program to check if a string starts with a specified word.


Note: Suppose the sentence starts with "Hello"
Sample Data: string1 = "Hello how are you?"
Result: Hello.
Sample Output:

7
Input a string : Hello how are you?
True

35. Check Numbers Less than 100 & Greater than 200

Write a C# program to check two given numbers where one is less than 100 and the other is greater
than 200.
Sample Output:
Input a first number(<100): 75
Input a second number(>100): 250
True

36. Check Integer in Range -10 to 10

Write a C# program to check if an integer (from the two given integers) is in the range -10 to 10.
Sample Output:
Input a first number: -5
Input a second number: 8
True

37. Remove 'HP' from String

Write a C# program to check if "HP" appears at the second position in a string and return the string
without "HP".
Test Data: PHP Tutorial
Sample Output:
P Tutorial

38. Extract 'PH' from String


Write a C# program to get a string of two characters from a given string. The first and second
characters of the given string must be "P" and "H", so PHP will be "PH".
Test Data: PHP
Sample Output:
PH

39. Largest and Lowest of Three Integers

Write a C# program to find the largest and lowest values from three integer values.
Test Data:
Input first integer:
15
Input second integer:
25

8
Input third integer:
30
Sample Output
Largest of three: 30
Lowest of three: 15

40. Nearest to 20 or Return 0

Write a C# program that checks the nearest value of 20 of two given integers and return 0 if two
numbers are same.
Test Data:
Input first integer:
15
Input second integer:
12
Sample Output
15

41. Check 'w' Appears 1-3 Times

Write a C# program to check if a given string contains the 'w' character between 1 and 3 times.
Test Data:
Input a string (contains at least one 'w' char) : w3resource
Test the string contains 'w' character between 1 and 3 times:
Sample Output
True

42. First 4 Chars Lowercase, Rest Uppercase


Write a C# program to create a string where the first 4 characters are in lower case. If the string is less
than 4 letters, make the whole string in upper case.
Test Data:
Input a string: w3r
Sample Output
W3R

43. Check String Starts with 'www'

Write a C# program to check if a given string starts with "w" and is immediately followed by two
"ww".
Test Data:
Input a string : www
Sample Output

9
False

44. Every Other Character in String


Write a C# program to create a string of every other character (odd position) from the first position of a
given string.
Test Data:
Input a string : w3resource
Sample Output
wrsuc

45. Count Specific Number in Array

Write a C# program to count a specified number in a given array of integers.


Test Data:
Input an integer: 5
Sample Output
Number of 5 present in the said array: 2

46. Check Number First or Last in Array

Write a C# program to check if a number appears as the first or last element of an array of integers. The
array length is 1 or more.
Test Data:
Input an integer: 25
Sample Output
False

47. Sum of Array Elements


Write a C# program to compute the sum of all the elements of an array of integers.
Test Data:
Array1: [1, 2, 2, 3, 3, 4, 5, 6, 5, 7, 7, 7, 8, 8, 1]
Sample Output
Sum: 69

48. First and Last Element Equal in Array

Write a C# program that checks if the first element and the last element of an array of integers are
equal. The array length is 1 or more.
Test Data:
Array1: [1, 2, 2, 3, 3, 4, 5, 6, 5, 7, 7, 7, 8, 8, 1]
Sample Output

10
True

49. First or Last Element Equal in Two Arrays


Write a C# program to check if the first or the last element of the two arrays (length 1 or more) are
equal.
Test Data:
Array1: [1, 2, 2, 3, 3, 4, 5, 6, 5, 7, 7, 7, 8, 8, 1]
Array2: [1, 2, 2, 3, 3, 4, 5, 6, 5, 7, 7, 7, 8, 8, 5]
Check if the first element or the last element of the two arrays ( leng th 1 or more) are equal.
Sample Output
True

50. Rotate Array Left

Write a C# program to rotate an array (length 3) of integers in the left direction.


Test Data:
Array1: [1, 2, 8]
After rotating array becomes: [2, 8, 1]

51. Max of First and Last in Array

Write a C# program to get the largest value between the first and last element of an array (length 3) of
integers.
Test Data:
Array1: [1, 2, 5, 7, 8]
Highest value between first and last values of the said array: 8

52. Middle Elements of Three Arrays


Write a C# program to create a new array of length containing the middle elements of three arrays (each
length 3) of integers.
Test Data:
Array1: [1, 2, 5]
Array2: [0, 3, 8]
Array3: [-1, 0, 2]
New array: [2, 3, 0]

53. Check Odd Number in Array

Write a C# program to check if an array contains an odd number.


Test Data:
Original array: [2, 4, 7, 8, 6]

11
Check if an array contains an odd number? True

54. Find Century of Year


Write a C# program to get the century of a year.

55. Max Product of Adjacent Elements

Write a C# program to find the pair of adjacent elements that has the largest product of the given array.

56. Check Palindrome String

Write a C# program to check if a given string is a palindrome or not.


Sample Example:
For 'aaa' the output should be true
For 'abcd' the output should be false

57. Max Product of Adjacent Integers

Write a C# program to find the pair of adjacent elements that has the highest product of an array of
integers.

58. Complete Missing Numbers in Range

Write a C# program that accepts a list of integers and checks how many integers are needed to complete
the range.
Sample Example [1, 3, 4, 7, 9], between 1-9 -> 2, 5, 6, 8 are not present in the list. So output will be 4.

59. Check Strictly Increasing Sequence


Write a C# program to check whether it is possible to create a strictly increasing sequence from a given
sequence of integers as an array.

60. Sum of Matrix with Zero Condition

Write a C# program to calculate the sum of all integers in a rectangular matrix. However, exclude those
integers located below an integer of value 0.
Sample Example:
matrix = [[0, 2, 3, 2],
[0, 6, 0, 1],
[4, 0, 3, 0]]
Eligible integers which will be participated to calculate the sum -
matrix = [[X, 2, 3, 2],
[X, 6, X, 1],

12
[X, X, X, X]]
Therefore sum will be: 2 + 3 + 2 + 6 + 1 = 14

61. Sort Integers Keeping -5 Fixed

Write a C# program to sort the integers in ascending order without moving the number -5.

62. Reverse Strings in Parentheses

Write a C# program to reverse the strings contained in each pair of matching parentheses in a given
string. It should also remove the parentheses from the given string.

63. Check Number in Array

Write a C# program to check if a given number is present in an array of numbers.

64. Get File Name from Path

Write a C# Sharp program to get the file name (including extension) from a given path.

65. Multiply Array Elements by Length

Write a C# Sharp program to multiply all elements of a given array of numbers by array length.

66. Min Value from Two String Numbers


Write a C# Sharp program to find the minimum value from two numbers given to you, represented as a
string.

67. Coded String Conversion

Write a C# Sharp program to create a coded string from a given string, using a specified formula.
Replace all 'P' with '9', 'T' with '0', 'S' with '1', 'H' with '6' and 'A' with '8'.
Sample Output:
969
J8V81CRI90

68. Count Specific Character in String

Write a C# Sharp program to count a specified character (both cases) in a given string.

69. Check All Uppercase or Lowercase

13
Write a C# Sharp program to check if a given string contains only lowercase or uppercase characters.

70. Remove First and Last Characters


Write a C# Sharp program to remove the first and last elements from a given string.
Sample Output:
Original string: PHP
After removing first and last elements: H
Original string: Python
After removing first and last elements: ytho
Original string: JavaScript
After removing first and last elements: avaScrip

71. Check Consecutive Similar Letters

Write a C# Sharp program to check if a given string contains two similar consecutive letters.
Sample Output:
Original string: PHP
Test for consecutive similar letters! False
Original string: PHHP
Test for consecutive similar letters! True
Original string: PHPP
Test for consecutive similar letters! True
Original string: PPHP
Test for consecutive similar letters! True

72. Check Array Average as Whole Number


Write a C# Sharp program to check whether the average value of the elements of a given array of
numbers is a whole number or not.
Sample Output:
nums = { 1, 2, 3, 5, 4, 2, 3, 4 }
Check the average value of the said array is a whole number or not: True
nums1 = { 2, 4, 2, 6, 4, 8 }
Check the average value of the said array is a whole number or not: False

73. Alphabetical Order of String Letters

Write a C# Sharp program to convert the letters of a given string (same case-upper/lower) into
alphabetical order.
Sample Output:
Original string: PHP
Convert the letters of the said string into alphabetical order: HPP
Original string: javascript

14
Convert the letters of the said string into alphabetical order: aacijprstv
Original string: python
Convert the letters of the said string into alphabetical order: hnopty

74. Odd or Even Length of String

Write a C# Sharp program to check the length of a given string is odd or even. Return 'Odd length' if
the string length is odd otherwise 'Even length'.
Sample Output:
Original string: PHP
Convert the letters of the said string into alphabetical order: Odd length
Original string: javascript
Convert the letters of the said string into alphabetical order: Even length
Original string: python
Convert the letters of the said string into alphabetical order: Even length

75. Nth Odd Number

Write a C# Sharp program that takes a positive number and returns the nth odd number.
Sample Output:
1st odd number: 1
2nd odd number: 3
4th odd number: 7
100th odd number: 199

76. Get ASCII Value of Character

Write a C# Sharp program to get the ASCII value of a given character.


Sample Output:
Ascii value of 1 is: 49
Ascii value of A is: 65
Ascii value of a is: 97
Ascii value of # is: 35

77. Check Word Plural

Write a C# Sharp program to check whether a word is plural or not.


Sample Output:
Is 'Exercise' is plural? False
Is 'Exercises' is plural? True
Is 'Books' is plural? True
Is 'Book' is plural? False

78. Sum of Squares in Array

15
Write a C# Sharp program to find the sum of squares of elements in a given array of integers.
Sample Output:
Sum of squares of elements of the said array: 14
Sum of squares of elements of the said array: 29

79. Integer to String and Vice Versa

Write a C# Sharp program to convert an integer to a string and a string to an integer.


Sample Output:
Original value and type: 50, [Link]
Convert string to integer:
Return value and type: 50, System.Int32
Original value and type: 122, System.Int32
Convert integer to string:
Return value and type: 122, [Link]

80. Convert Array Elements to Strings

Write a C# Sharp program to convert all the values of a given array of mixed values to string values.
Sample Output:
Printing original array elements and their types:
Value-> 25 :: Type-> System.Int32
Value-> Anna :: Type-> [Link]
Value-> False :: Type-> [Link]
Value-> 4/15/2021 10:37:47 AM :: Type-> [Link]
Value-> 112.22 :: Type-> [Link]
Printing array elements and their types:
Value-> 25 :: Type-> [Link]
Value-> Anna :: Type-> [Link]
Value-> False :: Type-> [Link]
Value-> 4/15/2021 10:37:47 AM :: Type-> [Link]
Value-> 112.22 :: Type-> [Link]

81. Check Swapped Two-Digit Number

Write a C# Sharp program to swap a two-digit number and check whether the given number is greater
than its swap value.
Sample Output:
Input an integer value:
Check whether the said value is greater than its swap value: True

82. Remove Non-Letter Characters

16
Write a C# Sharp program to remove all non-letter characters from a given string.
From Wikipedia,
A letter is a segmental symbol of a phonemic writing system. The inventory of all letters
form0000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000

17
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000

18
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000

s the alphabet. Letters broadly correspond to phonemes in the spoken form of the language, although
there is rarely a consistent, exact correspondence between letters and phonemes
Sample Output:
Orginal string: Py@th12on
Remove all characters from the said string which are non-letters: Python
Orginal string: Python 3.0
Remove all characters from the said string which are non-letters: Python
Orginal string: 2^sdfds*^*^jlljdslfnoswje34u230sdfds984
Remove all characters from the said string which are non-letters: sdfdsjlljdslfnoswjeusdfds

83. Remove Vowels from String


Write a C# Sharp program to remove all vowels from a given string.
Sample Output:
Orginal string: Python
After removing all the vowels from the said string: Pythn
Orginal string: C Sharp
After removing all the vowels from the said string: C Shrp
Orginal string: JavaScript

19
After removing all the vowels from the said string: JvScrpt

84. Indices of Lowercase Letters


Write a C# Sharp program to get the index number of all lower case letters in a given string.
Sample Output:
Orginal string: Python
Indices of all lower case letters of the said string:
12345
Orginal string: JavaScript
Indices of all lower case letters of the said string:
12356789

85. Cumulative Sum of Array

Write a C# Sharp program to find the cumulative sum of an array of numbers.


A cumulative sum is a sequence of partial sums of a given sequence. For example, the cumulative sums
of the sequence {x, y, z,...}, are x , x+y , x+y+z
Sample Output:
Orginal Array elements:
134567
Cumulative sum of the said array elements:
1 4 8 13 19 26
Orginal Array elements:
1.2 -3 4.1 6 -5.47
Cumulative sum of the said array elements:
1.2 -1.8 2.3 8.3 2.83

86. Count Letters and Digits in String


Write a C# Sharp program to get the number of letters and digits in a given string.
Sample Output:
Original string:: Python 3.0
Number of letters: 6 Number of digits: 2
Original string:: dsfkaso230samdm2423sa
Number of letters: 14 Number of digits: 7

87. Reverse Boolean Value

Write a C# Sharp program to reverse a Boolean value.


Sample Output:
Original value: False
Reverse value: True
Original value: True

20
Reverse value: False

88. Sum of Interior Angles in Polygon


Write a C# Sharp program to find the sum of the interior angles (in degrees) of a given polygon. Input
the number of straight lines.
From Wikipedia,
In geometry, a polygon is a plane figure that is described by a finite number of straight line segments
connected to form a closed polygonal chain or polygonal circuit. The solid plane region, the bounding
circuit, or the two together, may be called a Polygon.
Sample Output:
Input number of straight lines of the polygon:
Sum of the interior angles (in degrees) of the said polygon: -360

89. Count Positives and Negatives in Array

Write a C# Sharp program to count positive and negative numbers in a given array of integers.
Sample Output:
Original Array elements:
10 -11 12 -13 14 -18 19 -20
Number of positive numbers: 4
Number of negative numbers: 4
Original Array elements:
-4 -3 -2 0 3 5 6 2 6
Number of positive numbers: 5
Number of negative numbers: 3
Original Array elements:
Number of positive numbers: 0
Number of negative numbers: 0

90. Count Ones and Zeros in Binary

Write a C# Sharp program to count the number of ones and zeros in the binary representation of a given
integer.
Sample Output:
Original number: 12
Number of ones and zeros in the binary representation of the said number:
Number of ones: 2
Number of zeros: 2
Original number: 1234
Number of ones and zeros in the binary representation of the said number:
Number of ones: 5
Number of zeros: 6

21
91. Remove Non-Integer Values from Array
Write a C# Sharp program to remove all values except integer values from a given array of mixed
values.
Sample Output:
Original array elements:
25 Anna False 4/24/2021 11:43:11 AM -112 -34.67
After removing all the values except integer values from the said array of mixed values: 25 -112

92. Find Next Prime Number

Write a C# Sharp program to find the next prime number of a given number. If the given number is a
prime number, return the number.
From Wikipedia,
A prime number (or a prime) is a natural number greater than 1 that is not a product of two smaller
natural numbers. A natural number greater than 1 that is not prime is called a composite number. For
example, 5 is prime because the only ways of writing it as a product, 1 × 5 or 5 × 1, involve 5 itself.
However, 4 is composite because it is a product (2 × 2) in which both numbers are smaller than 4.
Primes are central in number theory because of the fundamental theorem of arithmetic: every natural
number greater than 1 is either a prime itself or can be factorized as a product of primes that is unique
up to their order.
Sample Output:
Original number: 120
Next prime number/Current prime number: 127
Original number: 321
Next prime number/Current prime number: 331
Original number: 43
Next prime number/Current prime number: 43
Original number: 4433
Next prime number/Current prime number: 4441

93. Square Root Without Built-In Functions

Write a C# Sharp program to calculate the square root of a given number. Return the integer part of the
result instead of using any built-in functions.
Sample Data:
(120) -> 10
(225) -> 15
(335) -> 18

94. Find Longest Common Prefix


Write a C# program that finds the longest common prefix from an array of strings.
Sample Data:
({ "Padas", "Packed", "Pace", "Pacha" }) -> "Pa"

22
({ "Jacket", "Joint", "Junky", "Jet" }) -> "J"
({ "Bort", "Whang", "Yarder", "Zoonic" }) -> ""

95. Validate Brackets in String

Write a C# programme to check the said string is valid or not. The input string will be valid when open
brackets and closed brackets are same type of brackets.
Or
open brackets will be closed in proper order.
Sample Data:
( "<>") -> True
("<>()[]{}”) -> True
("(<>”) -> False
("[<>()[]{}]”) -> True

96. Check All Characters Same in String

Write a C# Sharp program to check whether all characters in a string are the same. Return true if all the
characters in the string are the same, otherwise false.
Sample Data:
("aaa") -> True
("abcd") -> False
("3333") -> True
("2342342") -> False

97. Check Numeric String

Write a C# Sharp program to check if a given string (floating point and negative numbers included) is
numeric or not. Return True if the string is numeric, otherwise false.
Sample Data:
("123") -> True
("123.33") -> True
("33/33") -> False
("234234d2") -> False

98. Primes in Descending Order

Write a C# Sharp program to create and display all prime numbers in strictly descending decimal digit
order.
Sample Data:
2, 3, 5, 7, 31, 41, 43, 53, 61, 71, 73, 83, 97, 421, 431.....

99. Primes in Ascending Order

23
Write a C# Sharp program to create and display all prime numbers in strict ascending decimal digit
order.
Sample Data:
2, 3, 5, 7, 13, 17, 19, 23, 29, 37, 47, 59, 67, 79,

100. Equality of Value and Type

Write a C# Sharp program to check the equality comparison (value and type) of two parameters. Return
true if they are equal otherwise false.
Sample Data:
("AAA", "BBB") -> False
(true, false) -> False
(true, "true") -> False
(10, 10) -> True

101. Calculate Euler's Number (e)

Write a C# Sharp program to calculate the value of e.


Note: e is also known as Euler's number and Napier's constant
Sample Data:
e = 2.718281828459050

102. Create Identity Matrix

Write a C# Sharp program to create an identity matrix.


Sample Data:
Input a number: 3
100
010
001

103. Sort Characters in String

Write a C# Sharp program to sort characters in a given string (uppercase/lowercase letters and
numbers). Return the newly sorted string.
Sample Data:
("AAAbfed231") -> "AAAbdef123"
(" ") -> "Blank string!"
("Python") -> "hnoPty"
("W3resource") -> "ceeorrsuW3"

104. Compare Equality of Three Integers

24
Write a C# Sharp program to compare the equality of three integers and calculate how many integers
have the same value.
Sample Data:
(1,2, 3) -> 0
(1,3,3) -> 2
(3,3,3) -> 3

25

You might also like