BASTA
BASTA
• Computer programming is the process that professionals use to write code that
instructs how a computer, application or software program performs. Basically it is
a set of instructions to facilitate specific actions.
• Computer programmers create instructions for a computer to execute by writing
and testing code that enables applications and software programs to operate
successfully.
Objectives
1. Discuss the basic components of a computer (Both Software &Hardware).
2. Discuss brief overview of programming languages and the program development
life cycle.
3. Different number systems and conversions from one type to another will be
discussed.
Objectives
At the end of the lesson, the student should be able to:
• Identify the different components of a computer.
• Know about programming languages and their categories.
• Understand the program development life cycle and apply it in problem solving.
• Learn the different number systems and their conversions.
Introduction
• A computer is a machine that performs a variety of tasks according to specific
instructions.
• It is a data processing machine which accepts data via an input devices and its
processor manipulates the data according to a program.
Hardware
•Hardware is which the tangible part of the computer. It is composed of electronic
and mechanical parts.
Example of Hardware
• The Central Processing Unit
• Memory
• Input and Output Devices
Memory
• The memory is where data and instructions needed by the CPU to do its appointed
tasks can be found.
• It is divided into several storage locations which have corresponding addresses.
• The CPU accesses the memory with the use of these addresses.
.
• The Secondary Memory - is connected to main memory. It is used to hold
programs and data for long term use. Examples of secondary memory are hard disks
and CD-ROM. Secondary memory is considered as non-volatile storage. This means
that information residing in secondary memory is not erased after the computer is
turned off.
Software
• A software is the program that a computer uses in order to function. It is kept on
some hardware device like a hard disk, but it itself is intangible.
Some Types of Computer Programs:
• Systems Programs
• Application Programs
• Compilers
Some Types of Computer Programs:
•Systems Programs - Programs that are needed to keep all the hardware and
software systems running together smoothly.
• Example: Operating Systems like Linux, Windows, Unix, Solaris, MacOS
•Application Programs - Programs that people use to get their work done.
• Examples: Word Processor, Game Programs, Spreadsheets
•Compiler - The computer understands only one language (Machine Language).
Machine language is in the form of ones and zeros. Since it is highly impractical for
people to create programs out of zeros and ones, there must be a way of translating
or converting a language which we understand into machine language, for this
purpose, there exists compilers.
Example of Compiler
1. Java
2. Netbeans
3. Best C Compiler
4. C++
Answer: FORTRAN
2. Preoblem Analysis
• After the problem has been adequately defined, the simplest and yet the most
efficient and effective approach to solve the problem must be formulated.
• Usually, this step involves breaking up the problem into smaller and simpler
subproblems.
Example Problem:
Determine the number of times a name occurs in a list.
Input to the program:
list of names, name to look for.
Output of the program:
the number of times the name occurs in a list.
two types of errors that a programmer will encounter along the way.
• compile-time error – occur if there is a syntax error in the code. The compiler
will detect the error and the program won't even compile. At this point, the
programmer is unable to form an executable that a user can run until the error is
fixed. Forgetting a semi-colon at the end of a statement or misspelling a certain
command, for example, is a compile-time error. It's something the compiler can
detect as an error.
• Compilers aren't perfect and so can't catch all errors at compile time. This is
especially true for logic errors such as infinite loops. This type of error is called
runtime error.
Java -
class A {
public static void main (String args[]){
System.out.println(“HELLO WORLD”); }
}
C#
Class Program {
static void Main(string[] args) {
Console.Writeln(“HELLO WORLD”);
Console.Readkey(); }
}
PHP
<html> <Head>
<Title>PHP Hello World</title> </Head>
<body>
<?php
Echo “HELLO WORLD”; ?>
</body>
</html>
Java Script
<!doctype html> <Html>
<Head>
<Title>Hello World</title> </Head>
<body>
<script language = “Javascript”> alert (“Hello World”) </body>
</html>
Number System
Decimal
• We normally represent numbers in their decimal form.
• Numbers in decimal form are in base 10. This means that the only digits that
appear are 0-9.
•Here are examples of numbers written in decimal form: 12610 (normally written
as just 126)
1110 (normally written as just 11)
Binary
• Numbers in binary form are in base 2. This means that the only legal digits are 0
and 1.
• We need to write the subscript 2 to indicate that the number is a binary number.
•Here are examples of numbers written in binary form: 11111102
10112
Octal
• Numbers in octal form are in base 8. This means that the only legal digits are 0-7.
• We need to write the subscript 8 to indicate that the number is an octal number.
•Here are examples of numbers written in octal form: 1768
138
Hexadecimal
• Numbers in hexadecimal form are in base 16. This means that the only legal digits
are 0- 9 and the letters A-F (or a-f, lowercase or uppercase does not matter).
• We need to write the subscript 16 to indicate that the number is a hexadecimal
number.
•Here are examples of numbers written in hexadecimal form:
7E16 B16
Conversions