Solution to the rainbow exercise

This is a possible solution for the exercise in the C++ Simple Program tutorial.

// Include the input/output stream library

#include <iostream>  

// Indicate that commands are being used from the std namespace

using namespace std;  

// Begin the main function, specifying that
// there is an integer as the output but no inputs

int main(void){  

// Stream all the colours of the rainbow followed by
// an end of line character on seperate lines to the screen

    cout << "Red" << endl; 
    cout << "Orange" << endl; 
    cout << "Yellow" << endl; 
    cout << "Green" << endl; 
    cout << "Blue" << endl; 
    cout << "Indigo" << endl; 
    cout << "Violet" << endl;   

// Use the system command PAUSE to ask the user to press a key

system("PAUSE");
 

// Use the special code EXIT_SUCCESS as the return
// value for the main function. This means everything went OK.

return EXIT_SUCCESS;
 

} // End the main function