Your First Program
These instructions will take you through the process of creating and running a simple program. Displaying the words “Hello, world!” on the screen is a traditional first step when learning a new programming language. You will use Apple's Xcode integrated development environment to write a source code file in C++, then build and run the corresponding executable file.
If you haven't already, follow the steps in Starting a New Project to create a new project and source code file.
To create and run your program:
- Remove all of the code from the Xcode-generated
main.cppstarter file. You can do this quickly by clicking anywhere in the source code file, pressing Command+A on the keyboard to select everything, then tapping the Delete key to remove the selected code. Type the C++ code that appears below, but without the line numbers on the left. (Note: The last word on Line 10 ends with a lower-case ‘L’, not the number one.)
1// Program : "Hello, World!" in C++ 2// Author : Type your name here 3// Date : Fall 2025 4// Description: This program displays a greeting to the user. 5 6#include <iostream> // provides std::cout, std::endl 7 8int main() 9{ 10 std::cout << "Hello, world!" << std::endl; 11}When you have finished, press the triangular “Build and Run” (“Play”) button in the upper-left corner of the Xcode window to run your program.
If you've typed everything correctly, the program will start running and you'll see the words “Hello, world!” displayed in the console window below your source code. Congratulations! Proceed to Step 5; otherwise, continue with Step 4.

If you are instead greeted with one or more messages that there were errors found, proceed as follows:
- Carefully check what you've typed against the code that was given. Use the line indicated by each error as a guide to tracking down the source of the problem (the problem may be due to something typed on that line, or a line above).
- Once you've fixed as many errors as you can, press the “Build and Run” button to try again.
- If you get stuck, and cannot get a particular error to go away, ask your instructor or a classmate for assistance.
- After you see the words “Hello, world!” in the console window, edit the program so it displays a more personal greeting — e.g., “Hello, Casey!” (assuming that your name is Casey).
- Run your program again and verify that it works as expected. You should now see the personalized greeting message with your name.
Congratulations, you've completed your first CISP 301 program!