Logic gates

A logic gate is a digital circuit which either allows a signal to pass through it or to stop it.

This is the NOT gate                This is the OR gate                    This is the AND gate

An OR gate.

The output will be positive (True) if at least one input is true

An AND gate.

The output will be positive (true) when both inputs (the input one AND the input two) are positive (true).

A NOT gate (inverter)

Has only one input. It reverses the logic state.

A XOR gate.

It is true if only ONE of the inputs is true.
A NAND gate.

The output will be positive if either or both inputs are negative.

A NOR gate.

The output will be positive ONLY if all the inputs are false.

HTML and CSS

HTML stands for Hyper Text Markup Language.
It is used to present and create webpages in an easy and effective way.

Every webpage these days is created using HTML.

 

CSS stands for Cascading Style Sheets, it contains the formatting and structure of a webpage, and is written in HTML.

 

Problem solving exercise – microsoft test problem

– ›U2 has a concert that starts in 17 minutes and they must all cross a bridge to get there.
-› All four men begin on the same side of the bridge.
– ›You must help them across to the other side in under or at 17 minutes.
›- It is night. There is one flashlight.
›- A maximum of two people can cross at one time.
›- Any party who crosses, either 1 or 2 people, must have the flashlight with them.
›- The flashlight must be walked back and forth, it cannot be thrown, etc.
›- Each band member walks at a different speed.
– ›A pair must walk together at the rate of the slower man’s pace:
›= Bono: 1 minute to cross
= Edge: 2 minutes to cross
= Adam: 5 minutes to cross
= Larry: 10 minutes to cross
Goal: To get all 4 members across to the other side of the bridge in 17 minutes.
Problem: They have to get across the bridge in a limited amount of time.
Constraints/boundaries:  Each one person/pair must carry a flashlight. They each have different speeds of walking and if they’re in a pair they must both walk at the slower rate of walking. They only have 17 minutes. A maximum of 2 together can cross at a time.
Resources: Bridge, flashlight
Ownership: You have to get them across in 17 minutes.

Parity

A parity bit, or check bit, is a bit that is added to ensure that the number of bits with the value one in a set of bits is even or odd. Parity bits are used as the simplest form of error detecting code.

There are two variants of parity bits: even parity bit and odd parity bit. When using even parity, the parity bit is set to 1 if the number of ones in a given set of bits (not including the parity bit) is odd, making the number of ones in the entire set of bits (including the parity bit) even. If the number of ones in a given set of bits is already even, it is set to a 0. When using odd parity, the parity bit is set to 1 if the number of ones in a given set of bits (not including the parity bit) is even, keeping the number of ones in the entire set of bits (including the parity bit) odd. And when the number of set bits is already odd, the odd parity bit is set to 0. In other words, an even parity bit will be set to “1” if the number of 1s + 1 is even, and an odd parity bit will be set to “1” if the number of 1s +1 is odd.
Questions – pg 112

a) 00100001

b)01010011

c)11000011

d)11001001

Q2.a)011010011

b)011100011

c)101101001

d)011100101

e)111101110

f)011100011

g)101100101

1Dimensional arrays

A 1 Dimensional array is a series of objects all of which are the same size and type. Each object in an array is called an array element. For example, you could have an array of integers or an array of characters or an array of anything that has a defined data type. The important characteristics of an array are:

  • Each element has the same data type (although they may have different values).
  • The entire array is stored contiguously in memory (that is, there are no gaps between elements).

Arrays can have more than one dimension. A one-dimensional array is called a vector ; a two-dimensional array is called a matrix.
Here is an example program that allows the user to enter up to 30 programs (allowing them to specify within that how many they want), then it allows them to pick a number to show the name that corrosponds to that number.

program arraysstudentno;

{$mode objfpc}{$H+}

uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,crt
{$ENDIF}{$ENDIF}
Classes
{ you can add units after this };

{$R *.res}
var
students:array[1..30] of string;
nostudents:integer;
x:integer;
studentno:integer;
begin
writeln(‘How many students would you like to enter?’);
readln(nostudents);
for x:=1 to nostudents do
begin
writeln(‘Enter your students now, press enter between each name’);
readln(students[x]);
end;
writeln(‘Enter the name of the student you wish to see’);
readln(studentno);
writeln(students[studentno]);
readln;
end.