Unit 1 Rob Flashcards
What is a variable?
Variables are data values that can change when the user is asked a question, for example, their age.
Constants in C#
Constants can NOT change whilst the program is running, e.g const int passMark= 40;
What are the most common data types and what it does
boolean - true/false
Character - Single character
date/time - date and/or time
double - a number with a decimal such as 2.3
floating point. a number with a decimal e.g 4.5f
integer - A whole number
string - holds zero or more characters such as letters, numbers, spaces etc.
What are the there basic programming constructs:?
Sequence - the order in which instructions occur and are processed (order)
Selection - determines which path a program takes when it is running (IF)
Iteration - is the repeated execution of a section of code, when a program is running(LOOP)
What are the four basic programming operators?
Logical - AND OR NOT
Comparison - == = >= < ! =
Assignment - =
Arithmetic - + - * / DIV MOD
What is a sequence?
Sequence is the order in which instructions occur and are processed and if no conditions they’re done in order
What is a selection?
A selection determines which path a program takes when it is running, so the user is asked a question and if its answer is yes it will do 1 task and if the answer is no it will do another different task depending on the answer something will be done.
Iteration
Iteration is the repeated execution of a section of code when a programming is running until its complete (LOOP).
What is a logical operator?
AND OR NOT
What is a Comparison/relational operator?
== =>= < !=
What is an assignment operator?
=
What is an arithmetic operator?
+ - * / DIV MOD
What is readability?
refers how easy it is to read and understand code
What are the different types that help with readability?
Comments
Indentation
Naming
What is a comment?
Codes can be used to explain C# and to make it more readable, any text between // and the end of the line is ignored by C# and is just some text to help understand the code, and will not be executed.
What is indentation?
Indentation is the space between lines when coding and this saves lots of time while we revisit the code and use it, and this is because it allows the user to read it more quicker and understand it quicker e.g IF (you're reading this) { then stop } Instead of doing this, IF (you're reading this) {then stop} ALL in the same line
What is naming?
naming is basically as the name says, give meaningful names to variables, programs etc. because it allows the programmer to read the code faster when he’s searching for a variable than a random variable name.
What is a function?
On programming, there are often sections of the program that we want to re-use or repeat, “chunks” of instructions can be given a name, they are called functions and procedures.
What is declaring?
A function declaration tells the compiler about a function’s name, return type if any and parameters.
What is calling?
When a program calls a function, the program control is transferred to the called function. A called function performs a defined task.
What is validation?
Is an automatic computer check to ensure that the data entered is sensible and reasonable, for example the computer can be programmed to only accept numbers between 11 and 16 and that’s called range check.
Different types of validation
Length
Presence
Range
Format
What is length validation
The computer is programmed to check the data isn’t too short or too long
What is presence validation?
The computer checks whether a value is there or not, so maybe != null
What is range validation?
The computer checks that a value falls within the specified range, for example the computer can be programmed to accept numbers between 1-100 and it checks if the user did so do that.
What is format validation?
Format/data type validation is where the computer is programmed to check the data is in the right format, so int with whole numbers and float with decimals.
What is defining?
Defining is actually providing the actual body of the function/variable where as declaring you are only declaring its name, value and if any parameters without the actual body.