Programming principles

Subdecks (1)

Cards (53)

  • A computer is a programmable device that stores and processes data
  • Electronic devices accept data as input, process that data, produce output, and store the results
  • A computer is not intelligent; it cannot analyze a problem and come up with a solution
  • A human (the programmer) must analyze the problem, develop the instructions for solving the problem, and then have the computer carry out the instructions
  • Advantages of using computers:
    • Computers can repeat a solution very quickly and consistently once it's been written
    • Computers free people from repetitive and boring tasks
  • To write a program for a computer to follow, a two-phase process is required: problem-solving and implementation
  • Problem-solving phase:
    • Analyze
    • General Solution (Algorithm)
    • Test
  • Implementation Phase:
    • Specific Solution (Program)
    • Test
    • Maintenance
  • Identifiers in programming:
    • Variable names and class names are examples of identifiers
    • Choose names for variables that give an indication of their purpose
    • Rules for identifiers:
    • First character: a-z, A-Z, underscore "_", or dollar sign "$"
    • After the first character: a-z, A-Z, underscore "_", dollar sign "$", and digits 0-9
    • No spaces allowed
    • Uppercase and lowercase characters are distinct
  • Variable and Class names:
    • Start variable names with a lowercase letter
    • Start class names with an uppercase letter
    • Each subsequent word's first letter must be capitalized
  • Primitive Data Types:
    • Variables are classified according to their data type
    • Data type determines the kind of data that may be stored, memory usage, and data formatting
    • Examples of primitive data types:
    • byte, short, int, long, float, double, char
  • Primitive Data Types:
    • Data Types: byte, short, int, long, float, double, char
    • Memory Size and Range for each data type provided
  • Primitive Data Types ranking:
    • double
    • float
    • long
    • int
    • short
    • byte
    • Highest rank to lowest rank
  • The Integer Data Types:
    • Variables declared as a certain type
    • Values assigned to variables
    • Example code snippet demonstrating the use of integer data types
  • The Floating-Point Data Types:
    • Include float and double
    • Floating-point literals are assumed to be of the double data type unless suffixed with "F" to force it to be treated as a float
  • The boolean Data Type:
    • Allows variables to hold true or false values
    • Useful for evaluating conditions that are either true or false
  • The char Data Type:
    • Used to store characters
    • Can hold only one character at a time
  • Characters in C# are internally represented by numbers, with each character assigned a unique number
  • C# uses Unicode, a set of numbers used as codes for representing characters
  • Each Unicode number requires two bytes of memory, so char variables occupy two bytes
  • In C#, characters can be assigned using their Unicode numbers
  • Arithmetic operators in C# include: addition, subtraction, multiplication, division, and modulus
  • Addition operator in C# returns the sum of its two operands
  • Subtraction operator in C# returns the value of its right operand subtracted from its left operand
  • Division operator in C# returns the quotient of its left operand divided by its right operand
  • Multiplication operator in C# returns the product of its two operands
  • Modulus operator in C# returns the remainder of a division operation involving two integers
  • Integer division in C# results in an integer when both operands are integers
  • For a division operation to return a floating-point value in C#, one of the operands must be of a floating-point data type
  • Combined assignment operators in C# provide a faster way to perform arithmetic operations and assignment
  • C# automatically converts lower-ranked data types to higher-ranked data types in assignment statements
  • Three ways to comment in C# are: single-line comments (//), multi-line comments (/*...*/), and documentation comments (///)
  • Boolean logic is used in nearly every programming language
  • Boolean logic allows the translation of real-world problems into computer code
  • C, C++, and C# are three different computer programming languages that use similar syntax with operators like and, or, and not represented by different symbols
  • Gates are devices that perform basic operations on electrical signals
  • Gates accept one or more input signals and produce a single output signal
  • There are six fundamental types of gates: NOT, AND, OR, XOR, NAND, and NOR
  • Boolean algebra allows only two values: 0 and 1
  • A truth table defines the function of a gate by listing all possible input combinations and their corresponding outputs