markdown
Programming Fundamentalsmd bd150c5
lecture/information/programming/introduction-to-programming.lecture.n.md
Download PDF

Programming Fundamentals

date2026-07-14document_iddoc_f0e88254a7ce6fe5b40abf46ade12832descriptionプログラムを入力から出力を生成する手続として捉え、状態、制御フロー、分岐、反復、関数の基本を説明する。prerequisites四則演算 / 条件の読み取り / 手順の分解type講義statusactiverelateddata/lecture/information/information-engineering-portal.lecture.n.md / data/lecture/information/programming-languages/foundation/introduction-to-functional-programming.lecture.n.md / data/lecture/information/algorithm/foundation/computational-complexity-basics.lecture.n.md / data/lecture/information/algorithm/foundation/recursion-basics.lecture.n.md
informationprogrammingundergraduatelecture
data/lecture/information/information-engineering-portal.lecture.n.md

1Introduction

This lecture presents a program as a procedure that receives input and produces output. It describes execution in terms of state and control flow and explains the roles of variables, conditional branches, iteration, and functions.

2Basic Terms

An inputInput is data received from outside a program for use in a computation. An outputOutput is data presented outside the program as a computational result. Screen display, file access, and network communication are examples of inputoutputInputoutput; IO.

A stateState is the collection of values held by a program at a particular point during execution. A variableVariable is a name through which a program refers to a value. If a variable permits assignment, its associated value can be updated.

Control flowControl flow is the order in which the instructions of a program are executed. A conditional branchConditional branch selects the next operation according to the truth value of a condition, while iterationIteration repeats an operation under a specified condition.

A functionFunction is a named program component that receives input values as arguments, executes a sequence of operations, and returns a return value. Some languages also permit functions with no arguments or no return value.

3Describing Execution as State Transitions

If S is a state and c is one instruction, execution can be represented as a state transition

(c,S)S.

For example, if x=2 in state S, the assignment x := x + 1 produces a new state S in which x=3. Here := denotes an update and is distinct from mathematical equality.

4Branching and Iteration

if p then A else B executes A when condition p is true and B when it is false. while p do A executes A while p is true and then reevaluates p. Designing an iteration requires distinguishing the state updated on each iteration, the continuation condition, and the property that must hold at termination.

text
total := 0
for each score in scores:
    total := total + score
return total

In this example, scores is the input, total is part of the updated state, and return total determines the output. Processing each of n scores once performs n additions. A subsequent lecture on computational complexity formalizes this analysis.

5Decomposition into Functions

A function can have a specification that states its purpose, accepted inputs, return value, and effects on state or I/O. Decomposing a large procedure into functions with clear responsibilities makes each component easier to verify independently.

However, not every function determines its return value solely from its input values. Functions may update shared state or perform I/O. The next lecture on functional programming examines this distinction in detail.

6Summary

  • A program's behavior becomes clearer when its input, output, state, and control flow are distinguished.
  • A conditional branch selects an operation, whereas iteration repeats an operation.
  • Functions decompose a computation into units with explicit specifications.

7Next Lectures

data/lecture/information/programming-languages/foundation/introduction-to-functional-programming.lecture.n.md data/lecture/information/algorithm/foundation/computational-complexity-basics.lecture.n.md
raw .n.md をコピー
loc をコピー (filepath:line ~ line)
copy share link
copy encoded share link
path をコピー
copy share link
copy encoded share link
copy share link
copy encoded share link
タブを全て閉じる