C Basic Exercises
C Basic Exercises
2 x 3 x 6 = 36
5 * 3 = 15
9. Write a C# Sharp program that takes four numbers as input Test Data:
to calculate and print the average. Enter a digit: 25
Test Data: Expected Output:
Enter the First number: 10 25 25 25 25
Enter the Second number: 15 25252525
Enter the third number: 20 25 25 25 25
Enter the four number: 30 25252525
Expected Output:
The average of 10 , 15 , 20 , 30 is: 18 13. Write a C# program that takes a number as input and then
displays a rectangle of 3 columns wide and 5 rows tall using
that digit.
10. Write a C# Sharp program to that takes three
numbers(x,y,z) as input and print the output of (x+y).z and x.y Test Data:
+ y.z.
Enter a number: 5
Test Data:
Expected Output:
Enter first number - 5 555
Enter second number - 6 55
Enter third number - 7 55
Expected Output: 55
Result of specified numbers 5, 6 and 7, (x+y).z is 77 and x.y +
555
y.z is 72
-5
15. Write a C# program remove specified a character from a Input second integer:
non-empty string using index of a character.
25
Test Data:
Check if one is negative and one is positive:
w3resource
True
Sample Output:
wresource
19. Write a C# program to compute the sum of two given
w3resourc integers, if two values are equal then return the triple of their
sum.
3resource
Output:
w3resource
Enter first num: 4
Python
Enter second num: 4
Sample Output:
Output is 24
e3resourcw
nythoP
x
20. 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
17. Write a C# program to create a new string from a given
than second number.
string (length 1 or more ) with the first character added at the
front and back.
Sample Output: 21. Write a C# program to check the sum of the two given
integers and return true if one of the integer is 20 or if their
Input a string : The quick brown fox jumps over the lazy dog. sum is 20.
TThe quick brown fox jumps over the lazy dog.T
3682913
Sample Output:
29. Write a C# program to find the size of a specified file in
Odd numbers from 1 to 99. Prints one number per line. bytes.
1 Sample Output:
3 Size of a file: 31
1 12 25 -8
True
38. Write a C# program to get a new string of two characters
from a given string. The first and second character of the given
string must be "P" and "H", so PHP will be "PH".
34. Write a C# program to check if a string starts with a
specified word. Test Data: PHP
Result: Hello.
Sample Output: 39. Write a C# program to find the largest and lowest values
from three integer values.
Input a string : Hello how are you?
Test Data:
True
Input first integer:
15
35. Write a C# program to check two given numbers where
one is less than 100 and other is greater than 200. Input second integer:
Sample Output: 25
Input third integer:
False
40. Write a C# program to check the nearest value of 20 of
two given integers and return 0 if two numbers are same.
Test Data: 44. Write a C# program to create a new string of every other
character (odd position) from the first position of a given
Input first integer: string.
15 Test Data:
Input second integer: Input a string : w3resource
12 Sample Output
Sample Output wrsuc
15
Array1: [1, 2, 2, 3, 3, 4, 5, 6, 5, 7, 7, 7, 8, 8, 1] Highest value between first and last values of the said array: 8
Sample Output
True
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
Test Data:
Array1: [1, 2, 8]