eHow launches Android app: Get the best of eHow on the go.

How To

How to Write 'Hello World' in C++

Member
By drive9
User-Submitted Article
(2 Ratings)
Write 'Hello World' in C++
Write 'Hello World' in C++

Ever wish to be a software designer? Make your own video games? Write your own programs? The time has come to start making these goals a reality! This series ("Hello World!") will be your guidepost to help learn multiple programing languages, and concepts, as well as give you an opportunity to feel around each language and see which you like the most!

Difficulty: Easy
Instructions

Things You'll Need:

  • Computer
  • C++ Compiler
  1. Step 1
     

    Now, to start off, you're going to need to unify your libraries. #include iostream brings in the needed libraries for console input/output. So, the first line in your source portion of your compiler will be as pictured:

  2. Step 2
     

    To make codes much simpler as they build up, there's an option that greatly cuts out code not needed. using namespace std; keeps you from having to type std::cout each time that output is needed. The Second line will be as pictured:

  3. Step 3
     

    There has to be a portion that initiates the actual workable portion of the code. This is called int main(). So, our third line is as pictured, in red:

  4. Step 4
     

    Now that we have the part that initiates, we need to set up an area to initiate! We use { and } to contain the functional part of the code. So, our next line is as pictured, in green:

  5. Step 5
     

    The actual functional of this code is actually called cout. I remember best as see?-out (out being output) and it's exactly that. Output. This is the part of the code that will print out, "Hello,World!" This line is printed in blue:

  6. Step 6
     

    And, for our final line, we close the functional. Again, printed in green, in the picture:

Tips & Warnings
  • You can use cout as much as you like!
  • Not all compilers are equal! Some compilers will require slightly different code.
  • Programming can become HIGHLY addicting, and your love life, social life, and even virtual life can take a dangerous turn when practicing this art... CREATE AT YOUR OWN RISK!

Comments  

Flag This Comment

on 3/23/2009 very interresting

Subscribe

Post a Comment

Post a Comment

Related Ads

  • Have you done this? Click here to let us know.
I Did This
Tags
Get Free Computers Newsletters

Copyright © 1999-2010 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy .   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License. † requires javascript

eHow Computers
eHow_eHow Technology and Electronics