PDF download Download Article
Plus, learn how to write basic codes yourself with C++
PDF download Download Article

C++ is a programming language that programmers learn and later use on their computer. It is important to know that the computer does not understand the language of C++ directly, therefore it is the responsibility of the programmer to type in commands, which they can convert into a compilation for their computer to understand. For this tutorial, programmers will learn how to set up Xcode, an application that Apple users can use to understand how to run the app and write a code of their own. Since this article is mostly for those new to Xcode, a tutorial for how to write a code will be demonstrated as well.

  1. 1
    Download Xcode from the App Store. Be aware that Xcode can only be purchased through an Apple device only such as a MacBook, iPhone, iPad, etc. Non-apple users can set up C++ using other IDEs (Integrated Development Environments) such as Visual Studio or CodeBlocks.
  2. 2
    Open Xcode and agree to the terms and conditions. This will then install a few components for your computer.
    • It is crucial to accept these terms and conditions as you won't be able to use Xcode without them.
    Advertisement
  3. 3
    Select the icon that says Create a new Xcode project. This will help you make the C++ application that you've thought of making.
  4. 4
    Choose a template for the Xcode project. Pick macOS and select Command Line Tool
  5. 5
  6. 6
    Select a location for the Xcode project. This can be anywhere from a folder, your desktop, or a device where you'd like to save the project.
    • Creating a new folder just for C++ applications would be a useful idea.
  7. 7
    Click main.cpp to get access to the code.
    • Erase the entire code so you can rewrite the previous code on your own. This can be a good way to start off C++ for any person that is a beginner.
  8. 8
  9. 9
  10. 10
  11. 11
    Follow up by adding two curved brackets, {}, which will be the body of the function.
    • This is where the code will be written.
  12. 12
  13. 13
    Add statements such as cout, which is the output of the function. Make sure it is inside the middle of the bracket to create a working code.
    • Placing cout outside the brackets will cause the program to fail.
    • Be aware that cout will work for our code because we included #include<iostream> from a few steps earlier.
    • Adding statements allows you to further type out your code.
    • Although it points out an error, this can easily be fixed once the final code is complete.
  14. 14
  15. 15
    Insert quotation marks and write a sentence. For this example, use “Hello World!”
    • Any sentence of your preference can be used, but for this case it uses "Hello World!"
  16. 16
    Put two more operators,<<, to wrap up your code. You are almost done with your code.
  17. 17
    Finish the first line of code with endl. Endl wraps up the line and allows the user to start a new line of code. It informs our cout that there is no more code being added and that a new line needs to be integrated inside the function.
  18. 18
    Add a semicolon right after endl to conclude the end of that specific line. This is the end for the code.
  19. 19
    Run the code by clicking Run Program on the top left of Xcode. If the screen says Build Succeeded then the user has made a successful code.
    • Since "Hello World!" was typed out from a few steps prior, it should be what comes out of the output.
  20. 20
    Check the output on the bottom of the screen to see the code appear. Congratulations you've just created your own code!
  21. Advertisement

Expert Q&A

Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement

Tips

Submit a Tip
All tip submissions are carefully reviewed before being published
Name
Please provide your name and last initial
Thanks for submitting a tip for review!

Expert Interview

Thanks for reading our article! If you’d like to learn more about programming, check out our in-depth interview with Tyrone Showers.

You Might Also Like

Format Text as Code in Discord2 Simple Ways to Format Text Into Code on Discord
Change Code on Schlage Lock Change 4-Digit User Codes on Schlage Locks
Run a Program from the Command Line on LinuxRun a Program from the Command Line on Linux
Delay a Batch File Delay a Batch File: Timeout, Pause, Ping, Choice & Sleep
Reset Schlage Keypad Lock Without Programming Code Factory Reset a Schlage Lock & Restore the Default Programming Code
Convert from Binary to DecimalConverting Binary to Decimal: Positional Notation & Doubling
Download a GitHub Folder3 Ways to Download GitHub Directories and Repositories
Make an Exe FileMake an Exe File
Write PseudocodeLearn to Write Pseudocode: What It Is and Why You Need It
Convert from Decimal to HexadecimalConvert from Decimal to Hexadecimal: A Quick Guide + Examples
View Source Code View Source Code
Make a Program Using NotepadMake a Program Using Notepad
Create a Mobile App Develop a Mobile App: Planning, Designing, & Publishing
CodeCode
Advertisement

About This Article

Tyrone Showers
Co-authored by:
Technologist
This article was co-authored by Tyrone Showers. Tyrone Showers is a Technologist and the Co-owner of Taliferro Group, an IT consulting company based in Seattle, Washington. With over 35 years of professional experience, he specializes in API Design, e-Commerce, Operational Efficiency, and website development. He has a B.S. in Computer Science from DeVry Institute of Technology. This article has been viewed 74,666 times.
How helpful is this?
Co-authors: 9
Updated: December 9, 2024
Views: 74,666
Categories: Programming
Thanks to all authors for creating a page that has been read 74,666 times.

Is this article up to date?

Advertisement