Mada za sehemu hiiDesigning of computer programsMada 3
- Demonstrating application tools and environment used in programming
- Constructing pseudo-code and flow charts
- Implementing basic computer programming
Implementing Basic Computer Programming
After designing a program using pseudo-code or flowcharts, the next step is to convert that design into a program that the computer can execute. This process involves using a programming language (like C++), writing the source code, and using special software tools to run your program.

Integrated Development Environment (IDE)
An IDE is a software application that provides everything you need to write, edit, compile, and run programs. For this course, we use Borland C++ Builder.
Main parts of an IDE:
- Code Editor — a text editor specifically designed for writing program code; it recognizes programming language keywords
- Compiler — converts your source code into machine code (binary)
- Linker — combines object files into a single executable file
- Loader — loads the executable program into memory for execution
- Debugger — helps find and fix errors in your program
Step 1: Create a New Project
- Click File → New → Project
- Select EasyWin (.exe) from the list
- Name your project (for example,
program1) - Choose a drive other than C: (like D: or G:) to save your files
- Click OK
Step 2: Write Your Source Code
- Click File → New → Text Editor
- Type your C++ code
- Save the file with a
.cppextension (for example,myprogram.cpp)
Step 3: Add Files to Your Project
- Right-click on the
.exefile in the Project box - Select Add Node
- Type the filename (for example,
myprogram.cpp)
Step 4: Compile the Program
- Double-click on the
.exefile in the Project Box - If there are errors, read the error messages and fix them
- Repeat until the program compiles successfully
Step 5: Run the Program
- Right-click on the
.exefile - Select View → Run
Step 6: Debug (If Needed)
- Right-click on the
.exefile - Select View → Debug
When your program does not work correctly, the compiler or the program itself may show error messages. Here are common errors and how to fix them:
Syntax Error: Unexpected End of File
Cause: Missing a closing curly bracket } near the end of the file.
Fix: Check that every opening { has a matching closing }. Make sure all functions and control structures (if, while, for) have both opening and closing brackets.
Error: Newline in Constant
Cause: Missing quotation marks or incorrect syntax in printf or cout statements.
Example: cout<<"The number you entered is \n, num; ← Wrong!
Fix: cout<<"The number you entered is " << num << endl;
Error: Illegal Escape Sequence
Cause: Misplaced escape character like \n or \t outside quotation marks.
Example: cout<<"printing" \n ); ← Wrong!
Fix: cout<<"printing \n";
Program Error: Floating-Point Support Not Loaded
Cause: Trying to print a floating-point number using %f but the variable was declared as int.
Fix: Make sure your variable type matches what you are trying to print. Use float or double for decimal numbers.
Here is a simple program that asks the user to enter two numbers and displays their sum:
#include <iostream.h>
#include <conio.h>
void main()
{
int num1, num2, sum;
cout << "Enter first number: ";
cin >> num1;
cout << "Enter second number: ";
cin >> num2;
sum = num1 + num2;
cout << "The sum is: " << sum << endl;
getch();
}
How to run this program:
- Create a new project called
sumProgram - Write the code above in the text editor and save as
sum.cpp - Add
sum.cppto your project - Compile the program (look for errors and fix them if any)
- Run the program
- Enter two numbers when prompted — the program will display their sum
When practicing programming, always follow these steps:
- Create a new project and save it in an organized folder
- Write your source code using the code editor
- Compile the code and check for errors
- Run the program to see the output
- Use the debugger to find and fix logical errors
In Tanzania, shops and small businesses can use simple programs to calculate totals, manage inventory, or track daily sales. For example, a shopkeeper at Kariakoo Market could write a program to calculate the total price of goods (like 5 bags of rice at TZS 50,000 each) by using input, multiplication, and output — exactly as practiced in this topic. This helps reduce calculation mistakes and saves time during busy trading hours.
Jinsi utakavyotathminiwaTathmini ya mchakato · Tathmini ya matokeo · Tathmini ya maarifa
Tathmini ya mchakato
The student should be able to:
- Write clear,logically structured code for basic problems.
- Use proper syntax and programming conventions
- Debug and resolve errors during program execution.
Tathmini ya matokeo
Basic computer programs that run without errors and produce expected results.
Tathmini ya maarifa
Methods used: The trainee should explain how to:
- Write code using correct syntax and logic.
- Test and debug programs to identify and fix errors.
Principles: The student should explain the principle of:
- Logical flow in programming and problem-solving.
- Data types, variables, and control structures.
Theories: The trainee should explain: The trainee should explain:
- How algorithms translate into program logic.
- The role of control structures in decision-making and iteration.
Detailed knowledge about:
- Common programming errors and debugging techniques.
- Best practices in coding, including commenting and naming conventions.
- Using built-in libraries and tools to simplify coding tasks
Swali
What is the primary purpose of an Integrated Development Environment (IDE) in programming?
Ingia ili kuwasilisha jibu lako na lihesabiwe katika umahiri wako.
Ingia ili kufanya mazoeziMwalimu
Umekwama? Niulize chochote kuhusu mada hii.
Ingia ili kumuuliza Mwalimu wa AI wa Sonza kuhusu swali hili.
Ingia ili kuulizaMajadiliano
Hakuna maswali bado