Programming Fundamentals Flashcards
What is the structure to specify a new variable?
Type Identifier = Value
i.e int myAge = 30;
What syntax is used to create a variable without specifying its type?
var i.e var name1 = "John"
How do you write to console a sentence referencing variables using string interpolation?
Console.WriteLine($”Variable name is {varialbe}”)
$ calls variables enclosed in {} brackets
What is the procedure to redefine an existing variable?
Identifier = Value
You cannot reassign variable type once already defines
How do you write to console a sentence referencing variables without using string interpolation?
Console.WriteLine(“Variable name is {0} and age is {1}”, name, age)
You put the variables after the string which substitutes the values in {} brackets
What is the syntax for Boolean operators?
&& - and
|| - or
^ -xor
What is the most efficient way to increment a value by 1?
x++ /++x
What is the most efficient way to increment a value by more than 1?
x += 2
What is the syntax for comparison operators?
< > <= >= == !=
What is the construct of a for loop?
Initialisation, Test, Statement for(int i = 0; i < 10; i++) *Runs once regardless *Test is evaluated after statement is executed *You must use i
What is the construct for a do while loop?
do
{
} while();
What is a do while loop?
Executes its code once regardless of of the statement boolean value
What is a constant?
Immutable assigned value, does not change
What is an enumerator?
A distinct type that contains set of constants, with a default value of 0 that increments by 1
What is the construct to create a constant?
const name1 = "Yarn" Must specify const otherwise default is a variable