0% found this document useful (0 votes)
25 views5 pages

Notes - Unit 1 Part 1file

The document provides an overview of computer programming, defining it as the process of designing, writing, testing, and maintaining computer programs. It outlines the characteristics of a well-written computer program and algorithm, emphasizing accuracy, efficiency, user-friendliness, and adaptability. Additionally, it discusses the importance of algorithms in problem-solving and the standards used to measure their effectiveness, including correctness, time complexity, and space complexity.

Uploaded by

simeonbanda73
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views5 pages

Notes - Unit 1 Part 1file

The document provides an overview of computer programming, defining it as the process of designing, writing, testing, and maintaining computer programs. It outlines the characteristics of a well-written computer program and algorithm, emphasizing accuracy, efficiency, user-friendliness, and adaptability. Additionally, it discusses the importance of algorithms in problem-solving and the standards used to measure their effectiveness, including correctness, time complexity, and space complexity.

Uploaded by

simeonbanda73
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

BoCS1100 INTRODUCTION TO PROGRAMMING

UNIT 1 - Part 1
What is a Computer Program ?
Definition 1 : A computer program is a sequence or set of instructions for a computer to
execute in order to achieve a particular task(s).
Definition 2 : A computer program is a collection of organized instructions for a
computer to execute in order to achieve a particular task or set of tasks.

8 Important Characteristics of a Well Written Computer Program


● A Computer program should have a finite set of instructions. This means a computer
program must have a limited (not infinite) set of instructions.
● A computer program must be designed to perform a specific function or set of
functions. This means a computer program should have a task or objective that it
achieves
● A computer program should produce accurate and reliable results consistently. A
computer program that produces wrong or results that are not consistent is not a
good computer program.
● A computer program should use system resources efficiently and not consume too
much memory or processing power. This means a good computer program must use
the computer resources ( e.g : Hard Drive space, CPU power, Screen , etc)
efficiently) . A computer program that uses all the resources of your computer is not
a good program.
● A computer program should have a user-friendly interface and be easy to use, with
clear and concise documentation. This means that a computer program must be
easy to use for a majority of users. A computer program that is not easy to use for
most users is not useful.
● A computer program should be able to handle unexpected inputs or errors
gracefully, without crashing or corrupting data. This means that a computer program
must be able to detect and recover from some known but unexpected errors such as
lack of harddrive space and lack of memory. This is important because if a computer
program can recover from such unexpected errors, it would crash unexpectedly.
● A computer program should be able to run on different computers with different
hardware and operating systems. This means that a computer program must be
portable so that it is able to be installed and run on different systems. A computer
program that runs only on 1 system is less useful.
● A computer program should be easy to maintain and modify, with clear and
well-organized code. This means a computer program must be written in a way that
is easy for computer programmers to update it and add more features.
With those facts in mind, What is Computer Programming ?
Definition 1 : Computer programming is the process of designing, writing, testing, and
maintaining computer programs or software. It refers to the process of writing,
designing, and creating instructions for computers to execute so they can achieve a
particular task.

Computer programming generally encompasses 3 main activities.


1. The first step in computer programming involves formulating or developing
“solutions”, “recipes” , “techniques”, “methods” or “plans” for achieving tasks
using a computer program. These “solutions”, “recipes” , “techniques”, “methods”
or “plans” for achieving tasks are called algorithms in computer programming.
Part of formulating or developing algorithms includes documenting them.
Documenting algorithms is important because it enables communication and
analysis of the said algorithms.
2. The second activity involves converting the algorithms developed in the previous
step into a form that can be followed and executed by a computer. This typically
involves writing the steps in the algorithms into a set of instructions in a
computer programming language so that the computer can understand, accept
and follow the steps in the algorithm.
3. The final step in computer programming involves testing. Testing can be carried
out on either the algorithm or the code of the computer program. Testing is
referred to by different names at different points during the programming
programming process.

TIP : In Computer programming and software development the process of


writing the steps in an algorithm into a set of instructions in a
programming language is commonly referred to as “coding”.

Coding : Computer coding involves writing code in a programming language


that a computer can understand and use to perform specific tasks. This
process includes using specialized software development tools, such as
integrated development environments (IDEs), text editors, and compilers.
These tools help programmers to write, test, and debug their code to ensure
that it works correctly and efficiently.
Examples of Programming Languages include PHP, Java, Python, C++,
Python JavaScript , Perl , C++, C# , C.
Examples of a Computer Program In Different Forms
01111111 01000101 01001100 01000110
Let : A be = 1 00000010 00000001
Let : B be = 3 00000001 00000000 00000000 00000000
00000000 00000000
Let : C be A + B 00000000 00000000 00000000 00000000
Show Value of : C 00000011 00000000
00111110 00000000 00000001 00000000
00000000 00000000
01000000 00010001 00000000 00000000
00000000 00000000
mode code omitted

Pseudo Code Binary / Machine Code

using namespace std;

int main() {
int num1, num2;

std::cout << "Enter the first number: ";


std::cin >> num1;

std::cout << "Enter the second number: ";


std::cin >> num2;

int sum = num1 + num2;

std::cout << "The sum of " << num1 << " and " << num2
<< " is " << sum << std::endl;

cin.get();

return 0;
}

FlowChart Computer Program in the C++ Programming Language

What is a Computer Program Algorithm ?


An algorithm is a set of instructions or a collection of step-by-step activities that
outlines how to solve a problem or accomplish a particular task or goal. It can be
thought of as a recipe or a roadmap plan that guides a person or a machine (computer)
through a process to achieve a specific desired outcome or objective.
Algorithms In Computer Programming
In computer science, algorithms are used to solve problems and perform tasks such as
manipulating data, searching and sorting data, encrypting and decrypting information,
and optimizing processes. They are essential to the development of computer programs
and software, as they provide a framework for designing and implementing specific
functions and operations.
Algorithms can be expressed in various ways, such as in natural language, pseudocode,
flowcharts, or programming languages. The size and complexity of algorithms can
range from simple and straightforward to complex and sophisticated, depending on the
nature of the problem they are meant to solve.

8 Important Characteristics of a Good Computer Program Algorithm


● A good computer algorithm should solve the problem it was designed for accurately
and produce the expected output. An algorithm that does not achieve its purpose is
pointless for that purpose.
● A good computer algorithm should use the minimum necessary resources (time,
memory, or processing power) to solve a problem. An algorithm that uses a lot of
resources (harddrive space, CPU power, etc) is less useful compared to one that
uses fewer resources. Algorithms should be efficient!
● A good computer algorithm should be easy to understand and implement. An
algorithm that is twisted and difficult to understand is likely to confuse programmers
and may prove difficult to code.
● A good computer algorithm should be able to handle larger and more complex data
sets or tasks, as needed. An algorithm that cannot handle large, little data and
complex data is likely to result in a computer program that is not very useful.
● A good computer algorithm should be able to handle unexpected inputs or errors
gracefully, without crashing or corrupting data. This means an algorithm should be
able to handle errors in both the data.
● A good computer algorithm should be flexible enough to adapt to changing
requirements or new data sets without requiring significant modifications.
● A good computer algorithm should be modular and reusable in other contexts or
projects. This means that good algorithms should be portable such that they can be
used for other purposes with adequate changes and modifications.
● A good computer algorithm should be well documented and written in a clear and
understandable style, making it easier for other programmers to read and maintain
the code.
3 Important Standards Used To Measure Algorithms In Modern Programming
1. Correctness: The correctness of an algorithm refers to whether it produces the
expected output for a given input. Evaluating the correctness of an algorithm is
essential to ensure that it solves the problem accurately and reliably. This criterion
includes both functional correctness (the algorithm produces the expected
output) and non-functional correctness (the algorithm handles unexpected inputs
or errors gracefully, without crashing or corrupting data).
2. Time Complexity: The time complexity of an algorithm refers to the amount of
time it takes to complete a task, as a function of the size of the input data.
Evaluating the time complexity of an algorithm is essential to ensure that it can
solve the problem within a reasonable amount of time.
3. Space Complexity: The space complexity of an algorithm refers to the amount of
memory it uses to complete a task, as a function of the size of the input data.
Evaluating the space complexity of an algorithm is important to ensure that it can
solve the problem within the available memory constraints.

You might also like