General

C# Exercises for Beginners

Welcome to Practice C# Console! There are over 20 beginner C#exercises just waiting to be solved. The best way we learn anything is by practice and exercise questions. We have started this section for those (beginner) who are familiar with C#.

The answers are at the end of the post

 

C# Exercise Questions

1-) Which one ise valid variable?

2-) Define a variable that name is a “number” and assign a value of 100

3-) Write the types of the following variables

4-) Which of the following is correct for entering the newline after typed string in the console screen

4-) What is the output of the following code

6-) Fill the following blanks for read from the console application

7-) What kind of code do you enter for converting string to integer

8 -) How do you comment out a large block of code in C#

9-) What is the type of the “a” variable in the following code?

10-) Which of the following is correct defination for a constant

11-) Fill in the missing operator to calculate power of x.

12-) What is the output of the following code

13-) Which operator is used to calculate the remainder

14-) Fill the following blank for calculate b=b/5 by short syntax

15-) What is the output of the following code

16-) What is the output of the following code

17-) Which operator is used to check equality

18-) if “a” is higher than “b”, write “a is higher” else write “a is not higher”

19-) What is the output of the following code

20-) Fill the following blanks for write three times “hello world” on the console screen

C# Exercise Questions Answers

  1. userName
  2. int number;
    number=100;
  3. a:double, b:bool, c:string, d:int, e:char
  4. Console.WriteLine(“Hello”);
  5. 20
  6. Console.ReadLine();
  7. Convert.ToInt32(str);
  8. /* comment*/
  9. String
  10. const double PI=3.14159;
  11. *
  12. 4
  13. %
  14. /
  15. 5
  16. 4
  17. ==
  18. if, >, else
  19. 15
  20. while, <=, ++

The exercises consists of mainly college level , in fact, most exercises are directly from the book. My goal was to solve these exercises as a student would.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.