EN ES
Programming Concept

Basics

Control flow, variables, types, operators, basic I/O, and debugging fundamentals.

Chapter 2 (pp. 17–64) of Computer Science I.

Topics

SectionPageContent
Control Flow17Flowcharts; sequence of execution.
Variables18Naming rules/conventions, types, dynamic vs static typing, scoping.
Operators33Assignment, numerical, string concatenation, precedence, common numerical errors.
Basic Input/Output41Standard I/O, GUIs, printf()-style formatting, command-line input.
Debugging46Types of errors (syntax, runtime, logic); strategies.
Examples50Temperature conversion; quadratic roots.

Key Ideas

  • Static vs dynamic typing introduced here — contrasted concretely in the language parts (C static, PHP dynamic).
  • Scoping governs variable lifetime/visibility.
  • Common numerical errors (overflow, integer division, float precision) flagged early; revisited in searching & sorting (arithmetic overflow in midpoint calc).

Recurring Examples

Temperature conversion and quadratic roots — reappear in every language part.

Examples

Declaring and using variables

integer a ← 7
integer b ← 3
integer sum ← a + b       // 10
print sum

Integer division pitfall

print 7 / 2      // 3, not 3.5 — integer division truncates
print 7.0 / 2    // 3.5 — force a real operand

A classic numerical error: watch operand types.

In Java

int a = 7, b = 3;
int sum = a + b;               // 10
System.out.println(7 / 2);     // 3 — integer division truncates
System.out.println(7.0 / 2);   // 3.5 — one real operand promotes the result

Java is statically typed: the declared type fixes the operator’s behavior.

Citations

[1] Computer Science I, Ch. 2, pp. 17–64.