Unit No 4(Computer Programming Theory)
Unit No 4(Computer Programming Theory)
Computer Languages
• Imperative
• Procedural
• Object-Oriented
• Declarative
• Functional
• Data-Driven
• Logic
• Event-driven
• Aspect-Oriented
1. Imperative
2. Procedural
3. Object-Oriented
These procedures are attached to objects, allowing easier access and data field
modifications. Java, C++, C#, Python, Swift, Objective-C, Ruby, and PHP are a
few examples of object-oriented programming languages.
4. Declarative
It expresses computation logic without describing its control flow. SQL, HTML,
CSS, XAML, YAML, Haskell, and XML, are some most commonly used
declarative programming languages.
5. Functional
6. Data-Driven
7. Logic
The logic programming paradigm uses a set of rules and facts, to describe
constraints and relationships within a problem domain. Here rules are written
as logical clauses and follow a declarative approach. This programming
paradigm can be used to express knowledge without depending on the
implementation.
8. Event-driven
9. Aspect-Oriented
AOP is largely used to manage cross-cutting issues due to code duplication and
maintainability of the program in software systems. C++, .NET, Ruby, Spring
AOP, AspectJ, etc. are some popular examples of aspect-oriented programming
languages.
Programming process
Programming is an art, although we can learn and taught it, but the creativity
and problem solving skills are God gifted.
This is indeed the first Step to creating a program. And it involves getting
information about the program you are about to create. It is In this stage that
you determine what you want to achieve with your program, how you want to
achieve it, etc.
These informations are very important for the programmer because it provides
him the basis for planning about the program and to control the possible
difficulties that may arise.
2. Algorithm Design:
In this stage all the instructions which are to be performed at different stages
in the program are listed in simple English language. We may call it as a
strategy.
Let's takes a simple calculator program as an example. The algorithm will be.
3. Flowchart:
After writing the algorithm (i.e steps involved in the program), the next stage is
to present All the steps in a diagrammatic manner so as to make it easily
understandable. So the flowchart is simply the algorithm made clearer.
4. Coding:
In this stage we correct all the errors in the program, because there is a great
probability of mistakes occurring when coding.
Here the program is executed manually, called DRY RUN. This is done several
times until all the errors are removed from the program and the system become
error free.
6. Testing:
This stage is similar to debugging except that In this stage we test the program
by entering dummy data (includes usual, unusual and invalid data) to check
how the behavior of the program when given such data.
7. Final Output:
After going through all the above stages, the program is given the TRUE DATA.
Here the programmer expects the positive results of the program and expects
full efficiency of the program.
Algorithm
Definition:
Characteristics of an Algorithm
Flowchart
Flowcharts are used due to the numerous amount of benefits they provide.
3. Action/Process
A box represents arithmetic instructions, specific action or operation that
occurs as a part of the process. All arithmetic processes such as adding,
subtracting, multiplication and division are indicated by action/process
symbol.
4. Decision
Diamond symbol represents a decision point. Decision based operations such
as yes/no question or true/false are indicated by diamond in flowchart.
5. On-Page Connector/Reference
Whenever flowchart becomes complex or it spreads over more than one page,
it is useful to use connectors to avoid any confusions. connectors are used to
indicate a jump from one part of the flowchart to another without drawing
long or complicated lines. On-Page Connector is represented by a small circle.
6. Off-Page Connector/Reference
Whenever flowchart becomes complex or it spreads over more than one page,
it is useful to use connectors to avoid any confusions. connectors are used to
indicate a jump from one part of the flowchart to another without drawing
long or complicated lines. Off-Page Connector is represented by a pentagon.
7. Flow lines
Flow lines indicate the exact sequence in which instructions are executed.
Arrows represent the direction of flow of control and relationship among
different symbols of flowchart.
Rules For Creating a Flowchart
Algorithm
Flowchart
Now, there are various types of number systems that have their use cases. Let us discuss them
briefly.
Refer to the complete chart of number systems given below for a better understanding.
1. Decimal
The decimal number system or the base 10 number system uses 10 digits
ranging from 0 to 9 to represent any number. The first position from the
rightmost part of a decimal number is known as one’s place or unit’s place,
then the second position is known as ten’s place, and so on. Every decimal
number is represented by the power of base 10.
2. Binary
The binary number system or the base 2 number system uses only two digits i.e. 0 and 1 to
represent any number. For example, the decimal number 14 is represented as 1110 in the binary
number system. We need to keep dividing the decimal number by 2 until the quotient
becomes 0 and along with that, we need to remember the remainder. When the remainders
obtained in the division are represented in reverse order, a binary number is generated.
3. Octal
The octal number system or the base 8 number system uses 8 digits ranging
from 0 to 7 to represent any number. The octal number is very commonly used
the computer systems.
4. Hexadecimal
The hexadecimal number system or the base 16 number system uses 16 digits
ranging from 0 to 9 (i.e. 10 digits) and A to F (i.e. 6 digits) to represent any
number. Refer to the chart shown below to know the representation of
hexadecimal numbers.
We can convert a decimal number into a hexadecimal number. We need to keep
dividing the decimal number by 16 until the remainder becomes 0 and along
with that, we need to remember the remainder. When the remainders obtained
in the division are represented in reverse order, the hexadecimal number is
generated.
1. 13 ÷ 2 = 6, remainder 1 (LSD)
2. 6 ÷ 2 = 3, remainder 0
3. 3 ÷ 2 = 1, remainder 1
4. 1 ÷ 2 = 0, remainder 1 (MSD)
• Step 1: Divide the decimal number by 8, the base for octal numbers.
• Step 2: The remainder becomes the least significant digit of the octal
number.
• Step 3: The quotient is used as the new dividend, divided again by 8.
• Step 4: The new remainder becomes the next octal digit, positioned to
the left of the previous digit.
• Continue until the quotient is 0. The final remainder is the most
significant digit.
• Step 1: Divide the decimal number by 16, the base for hexadecimal
numbers.
• Step 2: The remainder becomes the least significant digit of the
hexadecimal number. Use 0-9 for remainders 0-9 and A-F for remainders
10-15.
• Step 3: Use the quotient as the new dividend and divide by 16.
• Step 4: The new remainder becomes the next hexadecimal digit, to the
left of the previous one.
• Repeat steps until the quotient is 0, with the last remainder being the
most significant digit.
• Hexadecimal equivalent: FE
•Step 1: Starting from the right (least significant bit, LSB), multiply each
binary digit by 2 raised to its position number, counting from 0.
• Step 2: Sum up the results of these multiplications to get the decimal
equivalent.
Example: Convert binary 11101011 to decimal.
• Step 1: Group the binary digits into sets of three, starting from the right.
If necessary, pad the leftmost group with zeros to make it a trio.
• Step 2: Convert each trio into its octal equivalent, which will range from
0 to 7.
• Step 1: Divide the binary number into groups of four, starting from the
right. Pad the leftmost group with zeros if it’s not already a quartet.
• Step 2: Convert each group into its hexadecimal equivalent, which will
be in the range 0-9 and A-F for 10-15.
• Step 1: Starting from the right (least significant digit, LSD), multiply
each octal digit by 8 raised to its position number, counting from 0.
• Step 2: Sum up these products to get the decimal equivalent.
• Octal digits: 2, 4, 7
• Binary equivalents: 010 (for 2), 100 (for 4), 111 (for 7)
• Step 1: Convert the octal number to binary by following the steps for
octal to binary conversion.
• Step 2: Group the binary digits into sets of four, starting from the right.
If necessary, pad the leftmost group with zeros to make it a quartet.
• Step 3: Convert each binary group into its hexadecimal equivalent, using
0-9 for values 0-9 and A-F for values 10-15.
• Result: 36532
• Decimal equivalent: 36532