Your first program · Coding Class
This topic is not available in the selected language or version. Showing the start of this section.
Apply the chapter in three steps: an exercise, a program project, and a debugging task. Implement first, then consult the hints and completion criteria. Use a separate file or working directory for each task.
1. Exercise · Print in order
Section titled “1. Exercise · Print in order”Write welcome.xen to print Hello, Xen! and My first program on separate lines in that order.
Completion: Output is exactly two lines without quotation marks.
Hint: Use two println calls inside main.
2. Build a program · Build an executable
Section titled “2. Build a program · Build an executable”Check the first exercise, build it with xen build welcome.xen -o welcome, and run ./welcome.
Completion: xen run and ./welcome print the same output; checking alone does not print the greeting.
Hint: check validates, run executes, and build creates an executable.
3. Debug · Find the source file
Section titled “3. Debug · Find the source file”Your source is in practice/, but you run xen run welcome.xen from its parent. Fix the invocation in two ways without duplicating the source.
Completion: Changing directory and specifying practice/welcome.xen both print the same two lines.
Hint: Check both the source argument and the shell’s working directory.
Verify and record
Section titled “Verify and record”Use xen check file.xen followed by xen run file.xen for ordinary programs; use xen test file.xen for test-only files. Record the original error, its cause, and the corrected result, then rerun every input in the completion criteria.