Programming Language Concepts: Expressions, Control Flow, and Subprograms

Posted by Anonymous and classified in Computers

Written on in English with a size of 4.81 KB

Expressions and Operators Fundamentals

Expressions Defined

What constitutes a valid expression in programming?

Understanding Operators

Operator Definition and Types

An operator is a symbol that represents a computation. What are the three primary types of operators?

  • Unary: Operates on one operand (e.g., -x).
  • Binary: Operates on two operands (e.g., x + y).
  • Ternary: Operates on three operands (e.g., (a > b) ? a : b).

Order of Operation and Precedence

How is the order of operation determined? What mechanisms can be used to change the default order of operation?

Order is typically governed by Operator Precedence Rules and Associativity Rules (e.g., left-to-right). Parentheses can be used to override the default order.

Conditional Expressions

What is a conditional expression? How are they implemented or written in various languages?

  • C/Java: max = (a > b) ? a : b;
  • Python: c = a if a > b else b

Side Effects in Expression Evaluation

What is a side effect, and how can side effects complicate expression evaluation?

A side effect occurs when a function changes a two-way parameter or a non-local variable. This complicates evaluation by introducing dependencies (Example: b = a + fun(&a);).

Overloaded Operators

What defines an overloaded operator?

Type Conversion Timing and Purpose

What is type conversion, and when does it typically take place?

Relational and Boolean Expressions

What is a relational expression?

What is a Boolean expression?

Short-Circuit Evaluation

What is short-circuit evaluation? How can it be used to protect an expression (e.g., preventing runtime errors like division by zero)?

Assignment Statements

What is an assignment statement? How is assignment handled differently in various languages (e.g., Haskell vs. C)?

Control Flow and Selection Structures

Control Statements and Structures

What is a control statement?

What is a control structure?

Two-Way Selection Statements

What is a two-way selection statement (e.g., if-else)? What are the key design issues related to two-way selection statements (e.g., the dangling else problem)?

Handling Nested Selection Statements

How are nested selection statements handled in various programming languages?

Multiple Selection Branches

What is a multiple selection branch (e.g., switch or case)? What are the design issues related to multiple selection branches?

Implementation Methods for Multiple Selection

What are two different common implementations of multiple selection branches?

Iterative Structures (Loops)

What is an iterative structure? What are the three main types of iterative structures, and what are the design decisions associated with these types?

Unconditional Branch Commands (GOTO)

What is an unconditional branch command? Why is this command considered dangerous in modern programming practices?

Subprograms: Abstraction and Design

Subprograms and Abstraction

Are subprograms considered process abstraction or data abstraction?

General Characteristics of Subprograms

What are the general characteristics that define subprograms?

Basic Subprogram Terminology

What are the basic definitions for subprograms?

  • Definition
  • Call
  • Header

Understanding Parameters

What are parameters? Define the following types:

  • Formal Parameters
  • Actual Parameters
  • Positional Parameters
  • Keyword Parameters

Procedures vs. Functions

How do procedures and functions fundamentally differ?

Key Design Issues for Subprograms

What are the critical design issues that must be considered for subprograms?

Referencing Environment

What is a referencing environment in the context of subprogram execution?

Parameter Passing Modes and Implementation

What are the three primary parameter passing modes (e.g., In, Out, In/Out)? How are those modes typically implemented, and how do common languages support them?

Passing Subprograms as Parameters

How are subprograms passed as parameters to other subprograms?

Overloaded Subprograms

What is an overloaded subprogram?

Generic Subprograms (Polymorphism)

What is a generic subprogram?

Advanced Subprogram Concepts

Closures Defined

What is a closure?

Coroutines Defined

What is a coroutine?

Related entries: