Solutions for those exercises.
Warm-up Exercises
-
Explain Boolean type
booland the meaning of logical operations AND (&&), OR (||) and negation (!). Provide a small example. -
Write a statement that declares a variable of type
intand sits its value to 3.
Questions
-
Write a statement that initializes a variable named
myHeightInMetersto your height in meters. What should be the datatype ofmyHeightInMeters, and why? -
What is wrong with the following? Will the error(s) appear at compilation time, or at execution time?
int age; Console.WriteLine("Please enter your age:"); age = Console.ReadLine(); -
What is the difference, if any, between 3 and “3”?
Problems
-
Declare and initialize 3 variables:
- Each variable should have a different data type
- Choose an appropriate name and value for each variable
Then display the value of each variable on the screen.