Module 2: Core Programming Language Concepts Flashcards
Define syntax.
Syntax is required to provide a set of rules that define how code is written in a specific programming language. There are various elements that make a programming language, such as keywords, code structure, symbols, layout, and even white space. Syntax can be considered as grammar for programming languages.
What are the different types of core data used in programs.
Core Data Types: byte sbyte decimal double float int uint long ulong short ushort
Core Character Data Types:
Char
String
Other Data Types:
Boolean
Enumerations
Describe and use variables.
Variable is a named storage location that points to a location in memory where the actual data is stored.
A variable must tell the compiler what type of data it can hold. The variable must also have a valid name and it must have a memory address that indicates where in the computer’s memory the value is stored. Lastly, the variable will also consist of a value assigned to it.
Variable names must begin with a letter or _. They are case sensitive for most programming languages. Variable names cannot be the same as the keywords in the programming language you are using and they must be unique within a program. They should also be descriptive to help represent the purpose of the variable in the program code.
To create a variable, you need to declare it. To declare a variable, you first provide a data type designator. After the data type designator, you provide a name for the variable. It is a good practice to ensure that you assign values to your variables when you create them.
Two distinct states when it comes to variable assignment, compile time and run time. Compile time is when the code is compiled for the platform on which it will execute. It also refers to the time when you are coding the application. Run time is when the application is compiled and is actually executing on the computer. Your applications might contain numerous variables with no data until the program is executed. You don’t have to keep the same value in a variable for the duration of execution of a program. You can change the value of a variable to suit your needs.
Describe and use constants.
A constant is similar to a variable. A constant must have a data type associated with it and it can be assigned a value. The difference between a constant and a variable is that a constant MUST be assigned a value at the time it is declared and that value can never change in the code or program. Therefore, a constant is known as an immutable value. You create a named memory location because you can use the named constant for values that should never change or where it would not make sense for the value to change.
byte
0 to 255 Unsigned 8-bit integer
int
-2,147,483,648 to 2,147,483,647 Signed 32-bit integer
uint
0 to 4,294,967,295 Unsigned 32-bit integer
long
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 Signed 64-bit integer
short
-32,768 to 32,767 Signed 16-bit integer
ushort
0 to 65,535 Unsigned 16-bit integer
Char
used to represent a single character, represented as a 16-bit Unicode character. Accepts three separate forms: character literal, hexadecimal and unicode. Consumes less resources in program than string.
String
a string is considered to be a series of characters. This series of characters can contain letters, symbols, and numbers. Essentially, a string is any value that can be represented by numeric data types and the char data type. Strings require special handling in programming languages because they are a collection or array of characters represented as a single entity. Because they are a series of characters stored in an array, you can also perform certain functions on strings such as extracting individual elements of the string from the collection, counting the number of characters in the string, and splitting the string into its individual characters. All these functions are handled through the string processing aspects of the programming language you use.
Boolean
There are two possible values for Boolean, true and false. You use bool data type to do comparisons in your programs. Used in decision structures, as values in looping structures to control the loop, and any other place where you might need to compare the result of some operation.
Enumerations
a listing of items. Enum is considered to be a data type that consists of named constants which are known as the enumerator list. The important aspect to keep in mind with enums is that by default, they start at 0.
Decimal
28-29 significant digits. May have a decimal point.