Central Queensland Linux User Group

  • home
  • faq's
  • hints, help and information
  • links
  • linux programming
  • media
  • events
  • about us
Home

Exercise 1

belly — Sat, 2011-03-05 08:45

This exercise has been designed to create and then compile your first C++ program as part of the basic “teachings” of using the GNU “g++” compiler.

In the tradition with initial programming, this exercise will focus on creating a “Hello World” C++ program.

A "Hello world" program is a computer program that prints out "Hello world" on a display device. It is typically one of the simplest programs possible in most programming languages. Therefore, by tradition, it often the first program taught in a beginning class on a particular language. It is also used to illustrate the most basic syntax of a programming language.  Cited (http://en.wikipedia.org/wiki/Hello_world_program)

Therefore I would ask those interested to try out the following:Create a hello.cpp file using your favourite text editor containing the following:

#include <iostream>

using namespace std;

int main()

{

   cout << "Hello World!" << endl;

   return 0;

}

  • Compile your newly created  C++ program using the following command line syntax (note, if you don’t have g++ installed, you will need to install it)

g++ hello.cpp -o hello

  • Then execute your newly compiled program using the following command:

./hello

  • You should see the following output

$ g++ hello.cpp -o hello

$ ./hello

Hello World!

  • Exercises
  • Login to post comments

Navigation

  • Recent posts

User login

  • Request new password

Events

Coming to a meeting soon!
Meetings for 2020
more

Who's online

There are currently 0 users and 0 guests online.
  • home
  • faq's
  • hints, help and information
  • links
  • linux programming
  • media
  • events
  • about us