cint

cint university / 101 / ced, the cint editor

101-00: welcome

This is lesson 101-00 of CU-101.2, checked against cint 0.2.0.

You will run your first program, change it and run it again.

what a program is

A program is a list of instructions that a computer carries out in order. A programming language is a way of writing those instructions down so that both you and the computer can read them. cint is a programming language about whole numbers, which programmers call integers. It makes one promise about its plain arithmetic signs, such as + and *: each answer is exact, or the program stops and tells you where and why.

You can run every program in this course in two places:

  • In your browser: each program on these pages has a Run button, and there is nothing to install.
  • On your computer: set up cint once, with an editor to write programs in and a terminal to run them. Then save a program in a file, and in the terminal type cint run and the file's name.

Use whichever you like. What a program prints is the same in both, down to the last character; only the messages about mistakes are laid out differently in the browser.

your first program

"Hello, world\n";

Run this program in ced

Run it. cint prints:

Hello, world

what happened

The program is one line, and that line is one statement: one instruction to the computer.

  • Text between double quotes, on its own, is printed. Programmers call printed text output.
  • \n does not print a backslash and an n. It means "end the line here", so that whatever comes next starts on a new line.
  • The semicolon ; ends the statement, the way a period ends a sentence.

change it

Change the program, then run it again. Guess what it will print before you run it.

  1. Print your own name instead of "world".
  2. Print two lines: put a second statement under the first, such as "Goodbye, world\n";.
  3. In the two-line program, delete the \n from the first line only.
what the third change prints
Hello, worldGoodbye, world
Without `\n`, the first line never ends, so the second statement's text follows it on the same line. If you printed your own name in step 1, it appears in place of the first "world".

what cint 0.2.0 does not do

Many first programs ask for your name and greet you, or roll dice. cint 0.2.0 cannot do either: it has no way to read what you type, no way to keep a piece of text in the program's memory and no random numbers. It does not draw pictures.

So every program in this course carries its numbers and text inside it. To try different text or a different number, you change the program and run it again, as you just did. Lesson 101-01 shows how much you can still draw with plain characters.

new words

program, statement, output, integer

Next: lesson 101-01, printing.