Link to the DIT Home Page

Dublin Institute of Technology, School of Computing
Ciarán O'Leary

  Home -> Teaching -> DT249-1 Programming and Algorithms -> Notes -> Week 01
  DT249-1 Programming and Algorithms

Week 01


Learning Outcomes:

Upon completion of this class, you should be able to:

  1. Explain what a computer program is.
  2. Outline the steps of a program in simple English.
  3. Write a simple computer program.

Tasks

1.

Download EditPlus from here. You can install this on your own laptop to use for editing programs. Alternatively, in the labs you can use TextPad (Start->Programs->Textpad) for the same function.

 

2.
You can download the compiler here - click on compiler (a description of the setup is here). Please note that although the compiler is for C++, we will be using it for C - a subset of the C++ programming language.

The compiler is the special program that will convert your source code, written in the C (note NOT C++) programming language from source code into executable code.

 

3.

To avoid getting certain errors over the course of this module, you must download this file and save it to c:\borland\bcc55\bin (Right Click -> Save As) in your own installation. This is not necessary if you are just using the installation in DIT.

 

4. Please note that this will install your compiler in a folder named c:\borland\bcc55\, so when you are setting the path environment variable in your programming tasks, please use the following command:

set PATH=%PATH%;C:\Borland\BCC55\Bin

This is in contrast to the set-up in the computer labs, where the compiler is installed in the c:\bcc55 folder, so in the labs you need to set the path as follows:

set PATH=%PATH%;C:\BCC55\Bin

As a shortcut, you can download the batch file here (right-click and save-as). Then, whenever you want to use your compiler, you can copy this file to the directory your code (.c files) is in, and execute as follows:

If you are in college, you can set your path from the command line in the folder where the code is located by typing

set_my_path DIT

If you are at home, and you've installed your compiler into c:\borland\bcc55 (as occurs by default), then you can set your path from the command line in the folder where the code is located by typing

set_my_path HOME

 

 
Running your Programs

 

5. Create a folder on your u: drive called programming. Note that if you are using your own laptop you should set up this folder on the c: drive. However, in order for me to see your programs, you must copy them to the u: drive in college at regular intervals. Your lab supervisor will help you with this.

Create a subfolder in programming named week_1.

Download paa_01_01.c (Right click -> Save As...) and put it in week_1.

 

6. Open a command prompt (Start -> Run -> type cmd). The command prompt provides you with a way to issue instructions to your operating system. In this case, we're going navigate the file system and tell the operating system to use the compiler program to convert our source code to executable code (this isn't even half as difficult as it sounds).

Change to your week_1 folder using the following commands:

u:
cd \
cd programming
cd week_1

 

7. Execute the following command:

set PATH=%PATH%;C:\BCC55\Bin

Remember, if you're doing this at home, use:

set PATH=%PATH%;C:\borland\BCC55\Bin

or use the batch file from step 4 as a short cut by typing

set_my_path DIT

(Note that to use the batch file, the file will need to be in the same folder as your command prompt.)

 

8. Compile your program using the following command:

bcc32 paa_01_01.c

This will create a file named

paa_01_01.exe

This is an executable file containing executable code for the Windows platform.

You can execute the program by typing

paa_01_01.exe

or simply

paa_01_01

 

9. Download, compile and run each of the following programs:
10. Write a simple program which asks the user to enter 10 numbers and then prints out their average (+ is the addition operator, / is the division operator).

Don't worry if you find this difficult - we will be going into a lot more detail in the future weeks.

See samples solutions here and here.

 

11.
To avoid getting some of the compiler errors you may be getting, you should do the following:

When compiling your code, you should provide a -P switch, which will allow your code to compile.

e.g.

bcc32 -P paa_09_12.c

Alternatively, you can edit the file bcc32.cfg in your borland\bin folder, and simply add in a line containing -P.


Further Reading

Chapter 1 of Paul Kelly book

 

Hit Counter  [Home][School of Computing][Dublin Institute of Technology]