W2 - Data Types Flashcards
Week 2
What are Data types?
Describes format and size of (i.e. memory occupied) a data item and defines what types of operation can be performed with that item.
What are the types of Data types?
Native and Custom data types.
What does Console.ReadLine() do?
It accepts user input
What is Int type?
This produces a whole number and it’s signed 32-bit integer (int32)
What is Char type?
This is a 16-bit numeric value. A char literal is delimited by a pair of single quotes (‘’).
What is Double type?
Doubles can have a functional part and it’s defined as a 64-bit floating point value.
What is a Decimal type?
A fixed precision number. Uses 128bit storage.
What is a variable in C#
A variable is a storage location in memory with a specific data type that holds a value.
What are the basic data types in C#?
The basic data types include:
int: Integer values.
double: Floating-point numbers.
char: Single characters.
string: A sequence of characters.
bool: Boolean values (true or false).
How do you declare a variable in C#?
A variable is declared by specifying the data type followed by the variable name (e.g., int age;).
What is an assignment statement in C#?
An assignment statement assigns a value to a variable (e.g., age = 25;).
What are constants in C#?
Constants are variables whose values cannot be changed once assigned. They are declared using the const keyword (e.g., const int DAYS_IN_WEEK = 7;).
How do you output data to the console in C#?
The Console.WriteLine() method is used to display text or variables in the console (e.g., Console.WriteLine(“Hello, World!”);).
How do you read input from the user in C#?
The Console.ReadLine() method is used to read input from the user as a string (e.g., string input = Console.ReadLine();).
What is type casting in C#?
Type casting is converting a variable from one data type to another. This can be implicit (automatic) or explicit (manual using a cast).