2. In the connection of C programming and
flowcharting, in this topic you will learn on
how to use algorithms.
Stay focus and study hard!
3. You will be able to
1. define pseudo code
2. write pseudo code on a specific problem
3. know the importance of algorithms
Objectives
4. Pseudo code is an informal high-level description
of the operating principle of a computer program
or other algorithm. It uses the structural
conventions of a normal programming language,
but is intended for human reading rather than
machine reading.
Pseudo code
6. #include <stdio.h>
main()
{
int x = 1;
if (x == 1)
printf("x is equal to one.");
else
printf(“x is not equal to one");
getch();
}
Write the pseudo code
7. Start
Header files
Opening bracket
Declaring x as integer and is equal to one
if x is equal to one then
print the statement x is equal to one
else
print the statement x is not equal to one
Get the character
Closing bracket
End
Pseudo code of the given previous code
8. You already had a fundamentals of writing an
algorithms. What’s next?
In the next topic you will be introduced on
how computers store data.
Stay in focus!
Heads up!
10. You will be able to
1. determine the function of 1 and 0
2. recognize different types of number
systems as they relate to computers.
3. add and subtract in binary
4. convert values from decimal, binary
Objectives
11. Concept:
All data that is stored in a computer is converted to
sequences of Zero’s and One’s.
Binary Number Systems
12. A computer’s memory is divided into tiny
storage locations known as bytes. One
byte is only enough memory to store a
letter of the alphabet or a small number.
Binary Number Systems
13. In order to do anything meaningful, a
computer has to have lots of bytes. Most
computers today have millions, or even
billions, of bytes of memory.
Binary Number Systems
14. Each byte is divided into eight smaller
storage locations known as bits. The term
bits stands for binary digit. Computer
scientists usually think of bits as tiny
switches that can be either on or off.
Binary Number Systems
15. Bits aren’t actual “switches,” however, at
least not in the conventional sense. In
most computer systems, bits are tiny
electrical components that can hold
either a positive or a negative charge.
Binary Number Systems
16. Computer scientists think of a positive
charge as a switch in the on position, and
a negative charge as a switch in the off
position.
Binary Number Systems
18. Figure shows the way that a computer
scientist might think of a byte of memory:
as a collection of switches that are each
flipped to either the on or off position.
Binary Number Systems
19. When a piece of data is stored in a byte,
the computer sets the eight bits to an
on/off pattern that represents the data.
Binary Number Systems
20. A bit can be used in a very limited way to
represent numbers. Depending on
whether the bit is turned on or off, it can
represent one of two different values.
Storing Numbers
21. In computer systems, a bit that is turned
off represents the number 0 and a bit that
is turned on represents the number 1. This
corresponds perfectly to the binary
numbering system.
Storing Numbers
22. In the binary numbering system (or binary,
as it is usually called) all numeric values
are written as sequences of 0s and 1s.
Storing Numbers
23. Here is an example of a number that is
written in binary:
10011101
Storing Numbers
24. The position of each digit in a binary
number has a value assigned to it. Starting
with the rightmost digit and moving left,
the position values are 2^0 , 2^1 , 2^2 ,
2^3 , and so forth.
Storing Numbers
26. Next figure shows the same diagram with
the position values calculated. Starting
with the rightmost digit and moving left,
the position values are 1, 2, 4, 8, and so
forth.
Storing Numbers
28. To determine the value of a binary number
you simply add up the position values of
all the 1s. For example, in the binary
number 10011101, the position values of
the 1s are 1, 4, 8, 16, and 128.
Storing Numbers
29. The sum of all of these position values is
157. So, the value of the binary number
10011101 is 157.
Storing Numbers
31. How? Just plot the table of the binary
values from 1, 2, 4, 8, 16, 32, 64 and so
forth below on the binary given.
Example:
1 0 1 1 1 0
32 16 8 4 2 1
Binary to decimal conversion – Simple way
32. Cancel all Zeros and Add all Ones
Then find the sum of 32, 8, 4 and 2.
Example:
1 0 1 1 1 0
32 16 8 4 2 1
Binary to Decimal conversion
33. • 101110
• 101010
• 11100101
• 101111011
• 1001011110
Try to convert, binary to decimal.
36. How? Just plot the table of the binary
values from 1, 2, 4, 8, 16, 32, 64 and so
forth.
Example: 46 is the given value
64 32 16 8 4 2 1
0 1 0 1 1 1 0
Decimal to Binary Conversion
37. • 128
• 201
• 134
• 96
• 52
Try to convert, decimal to binary .
66. Prepare ½ cross wise clean yellow pad
A.101 – 011 =
B. 1111 – 0101 =
C. 10101 – 01010 =
D.11101 – 10110 =
Binary Subtraction
67. Developed in the 1830s and 1840s by
Samuel Morse (1791-1872) and other
inventors, the telegraph revolutionized
long-distance communication. It worked
by transmitting electrical signals over a
wire laid between stations.
Morse Code & theTelegraph
68. In addition to helping invent the
telegraph, Samuel Morse developed a
code (bearing his name) that assigned a
set of dots and dashes to each letter of
the English alphabet and allowed for the
simple transmission of complex messages
across telegraph lines.
Morse Code & theTelegraph
69. In 1844, Morse sent his first telegraph
message, from Washington, D.C., to
Baltimore, Maryland; by 1866, a
telegraph line had been laid across the
Atlantic Ocean from the U.S. to Europe.
Morse Code & theTelegraph
70. Although the telegraph had fallen out of
widespread use by the start of the 21st
century, replaced by the telephone, fax
machine and Internet, it laid the
groundwork for the communications
revolution that led to those later
innovations.
Morse Code & theTelegraph
75. The class is divided into 4 groups,
each group must prepare 5 messages
using the Morse code. Write the
encrypted and decrypted messages
on a clean ¼ yellow pad paper.
Activity – Sender and Receiver
77. #include <stdio.h>
main()
{
int x = 1;
if (x == 1)
printf("x is equal to one.");
else
printf(“x is not equal to one");
getch();
}
1. Write the pseudo code
79. int x = 20;
int y = 10;
If (x < y) {
system.out.println(“x is less than y”);
}
If (x == y) {
system.out.println(“x is equal to y”);
}
If (x > y) {
system.out.println(“x is less greater than y”);
}
3. Write the pseudo code
80. Prepare ½ cross wise clean yellow pad
• 1101110
• 1011010
• 111010101
• 1011110111
• 10011011110
Try to convert, binary to decimal.
81. • 228
• 301
• 534
• 196
• 152
Try to convert, decimal to binary .