Notes from 11/5

blanks.cpp

#include <iostream>

using namespace std;

// Functions do not need to return values.
// The return type is then specified as "void".
void blankLines(int count);

int main()
{
    cout << "Intro to Programming in C++\n";
    blankLines(2);
    cout << "     5 November 2012\n";
    blankLines(4);
    cout << "by Chris League\n";
    return 0;
}

void blankLines(int count)
{
    for(int i = 0 ; i < count ; i++ ) 
    {
        cout << "\n";
    }
    //cout << "blankLines: " << count << endl;
}

chars.cpp

#include <iostream>
using namespace std;
void print_chars(int count, char c);

int main()
{
    print_chars(40, '=');  // single quotes around a character type
    cout << "\n";
    for(int i = 1; i <= 20; i++) {
        print_chars(i, '*');
        cout << "\n";
    }
    return 0;
}

functions.cpp

#include <iostream>

using namespace std;

// Function declarations should come first
float average(float x, float y);

// Once there's a declaration, function definitions
// can come in any order.

int main()
{
    cout << average(3, 5) << endl;
    return 0;
}

float average(float x, float y)
{
    return (x+y)/2;
}