Skip to content
EspañolWorkspace →

Subtraction in PSeInt: the - operator

Subtracts the right number from the left. Written before a number, it makes it negative.

Group:
Algebraic
Template
-
Open it in Codoritmo

Opens the editor with this example loaded. Run it step by step and watch the flowchart.

Worked example

A complete algorithm, ready to copy and run.

subtraction-operator.psc · 3 lines
Algoritmo Example    Escribir 10 - 3 - 2FinAlgoritmo

Output

Shows: 5 (worked left to right: 10 - 3 = 7, 7 - 2 = 5)

This is what the console shows when the example runs.

5

In a flowchart

This is how it appears in a flowchart, with the same shapes Codoritmo draws.

vuelto ← pago - total
Used inside a calculation. It has no shape of its own; it's used inside a calculation. Flowchart: a process rectangle reading "vuelto ← pago - total", with one arrow in and one arrow out.
Draw the flowchart of your own algorithm →

Template

The general form. Replace what's inside < > with your own data.

- · 1 line
-

Examples that use it

Programs from the example library where it appears, from the simplest to the most complete.

  • Can I Vote?

    Tells you whether you can vote or how many years you have left.

    Beginner
  • Parking Fee

    Charges every started hour, with a daily maximum.

    Intermediate
  • Guess the Number

    Guess a secret number from 1 to 100 in seven tries.

    Intermediate
  • Bubble Sort

    Sorts random numbers by swapping neighbors, and stops as soon as they're in order.

    Intermediate
  • Selection Sort

    Finds the smallest of the remaining numbers and puts it in its place.

    Intermediate
  • Insertion Sort

    Inserts each number among the sorted ones, like arranging cards in your hand.

    Intermediate
See every Math example →

More algebraic

Codoritmo is an independent, open-source project inspired by PSeInt and compatible with its syntax. It is not affiliated with the PSeInt project. Official PSeInt website.