Challenge Technical Guide - C++ Tutorial

This page will demonstrate how to compose, compile, and run a minimum C++ program and a slightly more advanced C++ program on the machine mode. You will not learn "why" the programs work from this page.

Begin by logging into mode. If you are not sure how to do this, make sure you read the information under the "Login Procedure" category in this guide.

Minimum Program: At the mode prompt, type "pico minprog.c" (no quotes), and press enter. Then, use the text editor Pico to enter the text as seen below.

Now save your file and quit pico. Once you are back at the mode prompt, we need to compile our program. To do this type "CC -o minprog.x minprog.c" (without the quotes), and press enter.

The "-o" means "redirect the output into the file name I give you", instead of naming the executable "a.out" (the default executable name). In this case that name given is "minprog.x".

If you receive error messages, use Pico to edit and fix the mistakes. Then re-compile your program as previously instructed. If there are no compiler error messages, you should see a file called "minprog.x" in your current working directory.

Type "ls" (no quotes) at the mode prompt to see that this file has indeed been created by the compiler. This is your executable (runnable) file.

Now, to run your file, type "minprog.x" (no quotes) at the mode prompt. You should see output similar to that below.

Advanced Program: Fire up Pico on a new file named "smallprog.c" and enter text as seen below.

Compile and run your program. Can you figure out how it worked?

New Mexico High School Supercomputing Challenge
Coordinated by Los Alamos National Laboratory and New Mexico Technet
Questions? e-mail: consult