C# Sharp Data Types : Exercises, Practice, Solution
C# Sharp Data Types Exercises [11 exercises with solution]
[An editor is available at the bottom of the page to write and execute the scripts.]
1. Write a C# Sharp program that takes three letters as input and display them in reverse order. Go to the editor
Test Data
Enter letter: b
Enter letter: a
Enter letter: t
Expected Output :
t a b
Click me to see the solution
2. Write a C# Sharp program that takes a number and a width also a number, as input and then displays a triangle of that width, using that number. Go to the editor
Test Data
Enter a number: 6
Enter the desired width: 6
Expected Output :
666666 66666 6666 666 66 6Click me to see the solution
3. Write a C# Sharp program that takes userid and password as input (type string). After 3 wrong attempts, user will be rejected. Go to the editor
Click me to see the solution
4. Write a C# Sharp program that takes two numbers as input and perform an operation (+,-,*,x,/) on them and displays the result of that operation. Go to the editor
Test Data
Input first number: 20
Input operation: -
Input second number: 12
Expected Output :
20 - 12 = 8
Click me to see the solution
5. Write a C# Sharp program that takes the radius of a circle as input and calculate the perimeter and area of the circle. Go to the editor
Test Data
Input the radius of the circle :
12
Expected Output :
Perimeter of Circle : 75.36
Click me to see the solution
6. Write a C# Sharp program to display certain values of the function x = y2 + 2y + 1 (using integer numbers for y , ranging from -5 to +5). Go to the editor
Click me to see the solution
7. Write a C# Sharp program that takes distance and time as input and displays the speed in kilometres per hour and miles per hour. Go to the editor
Test Data:
Input distance(metres): 50000
Input timeSec(hour): 1
Input timeSec(minutes): 35
Input timeSec(seconds): 56
Expected Output:
Your speed in metres/sec is 8.686588
Your speed in km/h is 31.27172
Your speed in miles/h is 19.4355
Click me to see the solution
8. Write a C# Sharp program that takes the radius of a sphere as input and calculate and display the surface and volume of the sphere. Go to the editor
Test Data:
Radius: 2
Expected Output:
50.26548
33.51032
Click me to see the solution
9. Write a C# Sharp program that takes a character as input and check the input (lowercase) is a vowel, a digit, or any other symbol. Go to the editor
Test Data:
Input a symbol: a
Expected Output:
It's a lowercase vowel.
10. Write a C# Sharp program that takes two numbers as input and returns true or false when both numbers are even or odd. Go to the editor
Click me to see the solution
11. Write a C# Sharp program that takes a decimal number as input and displays its equivalent in binary form. Go to the editor
Test Data:
Number to convert (or "end")? 25
Expected Output:
Binary: 11001
C# Sharp Code Editor:
More to Come !
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
- Exercises: Weekly Top 12 Most Popular Topics
- Pandas DataFrame: Exercises, Practice, Solution
- Conversion Tools
- JavaScript: HTML Form Validation
- SQL Exercises, Practice, Solution - SUBQUERIES
- C Programming Exercises, Practice, Solution : For Loop
- Python Exercises, Practice, Solution
- Python Data Type: List - Exercises, Practice, Solution
- C++ Basic: Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - exercises on Employee Database
- SQL Exercises, Practice, Solution - exercises on Movie Database
- SQL Exercises, Practice, Solution - exercises on Soccer Database
- C Programming Exercises, Practice, Solution : Recursion