Basics of C# This module introduces variables and data types in C#. Learn how to declare variables, assign values, and understand different data types.
What are Variables?
In C#, variables are storage locations that hold data. You declare a variable with a specific data type.
int myNumber = 10;
string myName = "Hannah";
bool isTeacher = true;
double pi = 3.14;
Questions
1. What is the correct way to declare an integer variable in C#?
2. Which data type should be used for a floating-point number?
3. What is the purpose of a variable in C#?
4. Which data type is used to store whole numbers in C#?
5. What will be the output of the following code?
int age = 15;
Console.WriteLine(age);