Tuesday, 27 December 2016

ByRef and ByVal

What is the difference between ByRef and Byval?

When you write a subroutine or function, you can pass variables from your main code to that subroutine or function.


If you want to pass the value of the variable, use the ByVal syntax. By passing the value of the variable instead of a reference to the variable, any changes to the variable made by code in the subroutine or function will not be passed back to the main code. This is the default passing mechanism when you don’t decorate the parameters by using ByVal or ByRef.

If you want to change the value of the variable in the subroutine or function and pass the revised value back to the main code, use the ByRef syntax. This passes the reference to the variable and allows its value to be changed and passed back to the main code.

Global/Local variables

Global variables are declared outside any function, and they can be accessed (used) on any function in the program. Local variables are declared inside a function, and can be used only inside that function. It is possible to have local variables with the same name in different functions.

In computer programming, a global variable is a variable with global scope, meaning that it is visible (hence accessible) throughout the program, unless shadowed. The set of all global variables is known as the global environment or global state.

Friday, 9 December 2016

Parity bit Model answer

The sender counts or checks the number of 1's in the bit pattern. If even number of 1's then a 0 parity bit is added. If it if odd then a 1 is added in the parity bit.

The receiver counts 1 checks the number of 1's in the bit pattern / data that is received. If odd then it is identified that an error has occurred and requests the data to be re-sent.
If it is even then it is assumed the data is correct however it does not mean it is correct.

Monday, 5 December 2016

Subroutines


What is it?

A routine or subroutine also referred to as a function, procedure, and subprogram is a portion of code that may be called and executed anywhere in a program. For example, a routine may be used to save a file or display the time. Instead of writing the code for these commonly performed tasks, routines are made and called when these tasks need to be performed. 


What is the difference between a subroutine and a function?

In my mind, the difference between function and subroutine is semantic. That is to say some languages use different terminology. A function returns a value whereas a subroutine does not.

Friday, 2 December 2016

Sampling rate and resolution

Rate-

Sample rate is the number of samples of audio carried per second, measured in Hz or kHz (one kHz being 1 000 Hz). For example, 44 100 samples per second can be expressed as either 44 100 Hz, or 44.1 kHz. Bandwidth is the difference between the highest and lowest frequencies carried in an audio stream.


Resolution-

A 16-bit recording uses 16 bits for each sample. 16 bits can represent 65,536 different numbers and amplitudes, which makes for a much better dynamic range. The sampling resolution is the representation (or size of the numbers) used to write samples in digital sound recording.


Calculating the file size given the sample depth, sample rate, sound time and channels

Formula
File size (bits) = sampling frequency (Hz) x sampling depth (bits) x length of sound (s) x channels

Example
A stereo song has to be recorded at CD quality. The song is 4 minutes and 8 seconds long. How much disk space would the captured song occupy?
Settings for CD quality are:
  • Sampling frequency = 44100 Hz (44.1KHz)
  • Sampling depth = 16 bit

Length of song = 4 x 60 + 8 = 248 seconds
File size (bits) = 44100 x 16 x 248 x 2 = 349977600
File size (bytes) = 349977600 / 8 = 43747200
File size (kilobytes) = 43747200 / 1024 = 42721.88
File size (megabytes) = 42721.875 / 8 = 41.72Mb

Monday, 28 November 2016

Arrays

In computer science, an array data structure, or simply an array, is a data structure consisting of a collection of elements (values or variables), each identified by at least one array index or key. An array is stored so that the position of each element can be computed from its index tuple by a mathematical formula.

In computer science, an associative array, map, symbol table, or dictionary is an abstract data type composed of a collection of (key, value) pairs, such that each possible key appears just once in the collection. Operations associated with this data type allow: the addition of a pair to the collection.

Image result for computer science array



A disk array is a hardware element that contains a large group of hard disk drives (HDDs). It may contain several disk drive trays and has an architecture which improves speed and increases data protection. The system is run via a storagecontroller, which coordinates activity within the unit.

An array is an aggregate data structure that is designed to store a group of objects of the same or different types. Arrays can hold primitives as well as references. The array is the most efficient data structure for storing and accessing a sequence of objects.

MIDI

MIDI (Musical Instrument Digital Interface) is a protocol designed for recording and playing back music on digital synthesizers that is supported by many makes of personal computer sound cards. Originally intended to control one keyboard from another, it was quickly adopted for the personal computer.

MIDI (Musical Instrument Digital Interface) is a protocol developed in the 1980's which allows electronic instruments and other digital musical tools to communicate with each other. MIDI itself does not make sound, it is just a series of messages like "note on," "note off," "note/pitch," "pitch-bend," and many more.

Image result for MIDIA MIDI interface is a device that provides MIDI In/Out to and from a computer or MIDI-equipped hardware via standard 5-pin MIDI jacks. There are standalone MIDI interfaces, virtually all of which connect to a computer via USB.

Thursday, 17 November 2016

Programming- Arrays

Arrays

An Array is a data structure that stores many items using a single variable.
An Array is like lots of boxes held together in a named variable. Each box has a position:

Dim Numbers(4) As Integer

the number 4 indicates the size of the Array.

Dim Exammarks(5) As single

Exammarks(0)= console.readline()
Exammarks(1)= console.readline()
...

It is useful to make use of For loops to easily imput the data into the Array.

Representing Sound in a computer

Analogue-  Analog refers to audio recorded using methods that replicate the original sound waves.


 Many times, digital audio companies try to hide this fact with fancy words like “Uncompressed” and “Lossless”. These words are very misleading as all digital audio features some compression and loss of the original signal. However, even the best trained human ear may not be able to tell the difference between a high quality digital signal and an analog audio signal.
An easy way to visualize digital audio is to consider the difference between a regular light bulb and a strobe light (Those lights designed to flash on and off very quickly. Commonly found at concerts or Halloween displays). In this example, an analog audio signal is comparable to a regular light bulb, whereas a digital audio signal would be similar to a strobe light. A strobe light can flash so fast that you hardly notice the moments when it is off.


Analog, Digital Audio Diagram

Digital-

Digital sound is broken down into thousands of samples per second. Each sound sample is stored as binary data.

Digital audio quality

Factors that affect the quality of digital audio include:

Sample rate - The sample rate is how many samples, or measurements, of the sound are taken each second. The more samples that are taken, the more detail about where the waves rise and fall is recorded and the higher the quality of the audio. Also, the shape of the sound wave is captured more accurately.

Each sample represents the amplitude of the digital signal at a specific point in time. The amplitude is stored as either an integer or a floating point number and encoded as a binary number.


Bit depth - the number of bits available for each clip

Bit rate - the number of bits used per second of audio
Sound waves coming out of a CD and VOIP. CD wave is smoother as is better quality


Monday, 14 November 2016

MetaData and File compression

Metadata- This is data that goes alongside a photo and has info on it like where it was taken, what format it is in, and the resolution.

Compression

Compression is the act of reducing the number of bits used to represent data.

PNG is a lossless type
often used when the image might be changed by another person. It retains a high quality while still have a reasonable file size.

Cameras often use their own format to store an image however it is often quite large due to it having a large resolution. 
Jpeg is often used because it is still a fairly high quality for a relatively small file size.

Gif's use 8 bits and are used for small animations.


Lossless compression- compressed image is as accurate as the original.

uses RUN LENGTH ENCODING. This means it shortens the number of bits needed to represent data by grouping it together.
b=blue
b,b,b,b,b,b,b,b can be shortened to 8b.

Lossy- there is more deg in the data.

Thursday, 10 November 2016

Glossary

Binary- a number system that uses base 2 and is the way computers process data.

Denary- The normal numbering system that uses base 10.

Integer- a whole number that can be positive or negative. Including 0.

Real Number- Any positive or negative number without a fractional part.

Ordinal number- any numbers which follow an order e.g 1-2-3-4.

Byte- 8 bits

Nibble- 4 bits

Bits- the smallest representative value for a computer to process. Can be a 1 or 0.

Metadata- data accompanies the image and has information on it.

Data types;
JPEG
PNG
GIF

Compression- the way of reducing the number the number of bits to represent data.

Lossless Compression- A way of compressing the data without losing any quality or accuracy.

Parity system- A way of checking if data is accurate and that it is complete and has not been tampered with.

Pixel- The smallest

Bit mapped graphics- Used pixels to display an image
Vector graphics- uses shapes and mathematical formula to construct an image

Trace table- A table that how numbers change when a program or code is followed.

Floating point number- A number r

2's Complement- a way of representing a negative number in a binary.

Mantissa- This is the main number. standard form has the decimal between a 0 and a 1.

Exponent- Tells us how far the decimal point is moved left or right.

RLE- Run length encoding,
A form of lossless compression in which a sequence is shortened. b,b,b,b=4b

Precision- how accurate something is.

Hexadecimal Representation- a way of representing numbers using 0-9 than letters for the numbers 10+. E.g 11=b

Bubble sort- a way of sorting numbers by comparing and swapping. each pass brings the largest number to the top each time until they are in order.


Hardware- The real physical/electrical components of the computer.

Software- Software is the

Application software-

Utility program- These help the computer by keeping the computer in an efficient state. They are in charge of the 'house keeping' such as deleting old files.

Library programs-

Translators-

Compiler-

Assembler-

Interpreter-

Operation system- This manages the system hardware and creates the 'virtual machine' for the user.

Virtual machine-

Resource management-

Processor-

Scheduling-

Memory management-

File management-

Peripheral-

Pseudo Code


Pseudocode


Most programs are developed using programming languages. These languages have specific syntax that must be used so that the program will run properly. Pseudocode is not a programming language, it is a simple way of describing a set of instructions that does not have to use specific syntax.


Common pseudocode notation

There is no strict set of standard notations for pseudocode, but some of the most widely recognised are:

INPUT – indicates a user will be inputting something

OUTPUT – indicates that an output will appear on the screen
WHILE – a loop (iteration that has a condition at the beginning)
FOR – a counting loop (iteration)
REPEAT – UNTIL – a loop (iteration) that has a condition at the end
IF – THEN – ELSE – a decision (selection) in which a choice is made
any instructions that occur inside a selection or iteration are usually indented

Example

 Set total to zero
Set grade counter to one
While grade counter is less than or equal to ten

    Input the next grade

    Add the grade into the total
Set the class average to the total divided by ten
Print the class average.

Trace Tables


Trace table


Trace tables are used to allow programmers to trace the value of variables as each line of code is executed. The values of the variables are displayed in a table and assist the programmer in identifying any potential errors.

Image result for Trace tablesImage result for Trace tables

Wednesday, 9 November 2016

2' Complement Binary


Representing negative integers


Negative numbers can also be represented in binary. The name of the system most commonly used to represent and handle negative numbers is '2s Complement'. There are two common methods used to figure out how a negative number is stored using 2s complement.
2's Complement

The first technique involves three steps:

Find the positive value

Switch 1s and 0s
Add 1



To represent -116, the following steps would be followed:

1. Find positive 116
128  64   32   16   8   4   2   1
   0    1     1     1    0   1   0   0




2. Switch 1s and 0s
128   64   32   16   8   4   2   1
 0       1     1     1    0   1   0   0
 1       0     0     0    1   0   1   1




3. Add 1

To add one, it is necessary to start at the right hand side of the number. If the number on the right is a 1, move to the next number. Keep moving from right to left until you find a 0.

In this example there is a 0 underneath the number 4. This 0 would become a 1. The 1s that are to the right of the 0 that was found first need to change from being a 1 to a 0:

128   64   32   16   8   4   2   1
  1      0     0     0    1   0   1   1
  1      0     0     0    1   1   0   0




10001100 = -116

Saturday, 5 November 2016

Graphics Exam Questions

1. (a) Figure 1 shows some of the drawing objects available with a vector graphics drawing software package.

Figure 1

(i) Name two properties which are common to Object 1 and Object 2.                    
1 Have the same line colour
2 Have the same fill colour   (2)

 (ii) When a designer creates a drawing, the size of various objects is often increased/decreased/moved as the drawing is being developed. Explain why no distortion occurs in vector graphics when the size of various objects is changed.

This is because vector graphics are stored using mathematical data and not lots of small dots, or pixels, so vector graphics can be scaled and moved without distortion.(2)

(iii) With vector graphics software, each new drawing is created as a set of vectored objects. Each drawing is created and saved in a file format specific to that brand of software. The software has an ‘export’ facility so that a bitmapped version of any drawing can be produced which can then be used as appropriate e.g. included in a word processed document. Why is this arrangement preferable to bitmapped-based software which only creates and saves a bitmapped file?
It allows you to do more with the graphics so it is more versatile. (1)

(b) Bitmapped software saves the picture as pixels, with a range of different possible colour resolutions as shown in Figure 2.    

  Figure 2


(i) If the graphic is saved as shown as a ‘256 color bitmap’, how many bytes will be used to store each pixel? 1 byte will be used (1)

 (ii) A picture is downloaded from a camera-phone and saved as a ‘256 color bitmap’. The picture has a width of 1280 pixels and height 768 pixels. What is the file size in Kilobytes? 983.04 (1)

 (iii) The same picture as in part (ii) is later loaded into bitmapped software on a PC and saved to a new file as a ‘16 color bitmap’. What is the size of this file in Kilobytes? 491.52  (1) (Total 8 marks)

2. (a) Figure 1 shows a number of drawing objects from the toolbox of a vector graphics drawing program. Figure 1 Object 1 Object 2 Basic Flowchart Shapes Process Data Internal storage Line-curve connector Decision Predefined process Sequential data Line connector Document Stored data Direct data Wavy connector

(i) For object 1 and object 2, state two properties common to both types of object, which would be recorded when used in a drawing.
1 Same line colour
2 Same fill colour    (2)

(ii) State one other property for object 1 which would be recorded when used in a drawing. Dimensions (1)

(iii) Graphics can be created with either vector graphics software or bit-mapped software. If the graphic is enlarged it may become distorted if created with bit-mapped software but show no distortion if created with vector graphics software. Explain this statement.
Bit mapped graphics software uses pixels instead of the mathematical ratios that that the vector graphics software does so when it is enlarged it will enlarge the pixels because that is the base type it uses. (2)

 (b) Figure 2 below shows the file type options available when saving a file with bit-mapped graphics software. Figure 2 File name: Save as type: Save Monochrome Bitmap (*.bmp;*.dib) 256 Color Bitmap (*.bmp;*.dib) 24-bit Bitmap (*.bmp;*.dib) JPEG (*.JPG;*.JPEG;*.JPE;*.JFIF) GIF (*.GIF) TIFF (*.TIF;*.TIFF) PNG (*.PNG) 16 Color Bitmap (*.bmp;*.dib) Cancel This Picture 16 Color Bitmap (*.bmp;*.dib)

 (i) How many bits are used to store each pixel if the resolution selected is as shown (‘16 color bitmap’)?’ 4 (1)

 (ii) ‘256 color’ images are stored with 1 byte per pixel. Explain this statement.
Each pixel takes 8 bits to reperesent all 256 colours and 8 bits is a byte. (1)

(iii) Read again the statement in part (ii). A picture with size 1024 by 768 pixels is saved as a ‘256 color’ image. Calculate the picture size in Kilobytes.  
786.432Kb (1)

 (iv) Black and white (monochrome) bit-mapped files store each pixel with a single bit. A black and white image of size 512 by 256 pixels has a calculated file size of 16 Kilobytes. The actual file size is larger than this calculated size as the bitmap file contains other data. What is this other data?
The file name and format type (1) (Total 9 marks)

 3. Bit patterns can be interpreted in a number of different ways. A computer word contains the bit pattern 0011 0100. (a) What is its decimal value if it represents: a pure binary integer;
52. (1)

 (b) (i) The ASCII value for the character ‘0’ (zero) is 48. What character is represented by 0011 0100?
the number 4 (1)

 (ii) Name one other standard coding system for coding information expressed in character or text-based form.
Unicode (1)

(c) One method of representing graphics in a computer system is as bit mapped graphics.
 The black line on the left might be represented as (i) Describe how a coloured line might be represented. ............................................................................................................................ ............................................................................................................................ ............................................................................................................................ (2)

 (ii) Describe how a line would be stored using vector graphics. ............................................................................................................................(3) (Total 8 marks)

Progress Assessment one Corrections

Q4) D) There can be a loss of precision when a denary number is stored using this floating point system. The closest possible representation of 6.9 is

0.1101110    0011

By converting this bit pattern back into denary we can see that the actual number is 6.875, not 6.9.
Calculate the absolute error that has occurred.
6.9-6.875=0.025

ii) Calculate the relative error that has occurred.
0.025/6.9=0.0036

Q5) For each of the following, name a suitable data type and give a reason for your choice.
a) The number of books a student has out on loan from the college libary.
Integer - Need to store whole numbers and add or subtract them as he takes is or brings back books.

b)A students average mark to two decimal places.
Single - can handle calculations and numbers with decimals in.

c) Telephone number such as 01223123456.
String - needs to be string and not single or integer so beginning 0 does not disappear.

Q8) This question is based around the pre-released code.

a)Give a line of code where a relational operator is used.
If num < num2 then

d) Give a line of code in which an assignment statement is used.
num1=console.readine

Vector Grapics


What are vector graphics?


Vector graphics are created in graphics packages and consist of shapes called objects.

It is possible to edit each object separately, for example, change the shape, colour, size and position.

Even if an object in a vector graphic is quite large, it doesn't need a lot of computer memory. Therefore the file size of a vector graphic is often very small.

Vector graphics are scalable - ie. when you resize them, they do not lose quality.


Because vector-based images are not made up of a specific number of dots, they can be scaled to a larger size and not lose any image quality. If you blow up a Bitmap graphic, it will look blocky, or "pixelated." When you blow up a vector graphic, the edges of each object within the graphic stay smooth and clean. This makes vector graphics ideal for logos, which can be small enough to appear on a business card, but can also be scaled to fill a billboard. Common types of vector graphics include Adobe Illustrator, Macromedia Freehand, and EPS files. Many Flash animations also use vector graphics, since they scale better and typically take up less space than bitmap images.

What is a vector in animation?

Vector animation is a term used to refer to animation in which the art or motion is controlled by vectors rather than pixels. Vector animation often allows cleaner, smoother animation because images are displayed and resized using mathematical values instead of stored pixel values.

Tuesday, 1 November 2016

VB Loops

Summary

Use a For ... Next loop if we know before entering the loop how many times we want to repeat the group of statements.

Use Do While ... Loop if the group of statements is only to be executed under certain conditions.

Use a Do ... Loop Until when we want to execute a group of statements at least once.

An infinite loop is one that never stops running.

Bits and Byte Prefixes

Nibble = 4 bits
x2 Nibbles = 1 byte = 8 bits
Kb= Kilobit = 1000 bits = 125 bytes
Mb = Megabit = 1,000,000 bits

KB = Kilobyte = 10^3 = 1000 bytes
MB = Megabyte = 10^6 = 1,000,000 bytes
GB = Gigabyte = 10^9 = 1000 MB
TB= Terabyte = 10^12 = 1000 GB

Ki (KiB) = Kibibyte = 2^10 = 1024 bytes
Mi (MiB) = Mebibyte = 2^20 = 1,048,576
Gi (GiB) = Gibibyte = 2^30 = 1024 Mi
Ti (TiB) = Tebibyte = 2^40 = 1024 Gi

Monday, 31 October 2016

Bitmapped Graphics

What are bitmap graphics?

When you take a photograph using a digital camera or scan an image from a magazine, you are creating a bitmap graphic.

A bitmap graphic is composed of many tiny parts, called pixels, which are often many different colours. It is possible to edit each individual pixel.

Since the computer has to store information about every single pixel in the image, the file size of a bitmap graphic is often quite large.

When you resize a bitmap graphic, it tends to lose quality.

Bitmap files are especially suited for the storage of real-world images; complex images can be rasterized in conjunction with video, scanning, and photographic equipment and stored in a bitmap format.

Advantages of bitmap:

Bitmap files may be easily created from existing pixel data stored in an array in memory.

Retrieving pixel data stored in a bitmap file may often be accomplished by using a set of coordinates that allows the data to be conceptualized as a grid.

Pixel values may be modified individually or as large groups by altering a palette if present.

Bitmap files may translate well to dot-format output devices such as CRTs and printers.

Bitmap drawbacks:

They can be very large, particularly if the image contains a large number of colors. Data compression can shrink the size of pixel data, but the data must be expanded before it can be used, and this can slow down the reading and rendering process considerably. 
Also, the more complex a bitmap image (large number of colors and minute detail), the less efficient the compression process will be.

They typically do not scale very well. Shrinking an image by decimation (throwing away pixels) can change the image in an unacceptable manner, as can expanding the image through pixel replication. Because of this, bitmap files must usually be printed at the resolution in which they were originally stored.

Bitmap graphics software

Bitmap graphics can be created and edited using packages such as:
  • Microsoft Paint
    Adobe Photoshop

Tuesday, 25 October 2016

Daily Dose Practice Exam questions

Q1. 

(a)     Explain the difference between hardware and software.
Hardware is the physical components parts of the computer. Example of a piecie of hardware is the computer motherboard.
Software is the program and code or instructions that the computer is given to use.

(b)     (i)      Which of the following is a typical value for the clock speed of a processor?
512 MB         128 kbps              80 GB           2 Mb/s             3.0 GHz
(circle your answer)
(ii)     Which of the following is a typical value for the capacity of a memory card for use with a digital camera or other device?
512 MB         256 bits/sec         50 GB           2 bytes            3.0 GHz
(circle your answer)
Q2.
A program has been written to analyse the results of a survey.  For each of the following, name a suitable data type and give a reason for your choice:
(a)     number of cars owned by a household;
data type: Integer
reason: Dealing with whole numbers only





(b)     a telephone number such as 0122456789;
data type: String
reason: So leading zeros do not dissapear and because it will not need calculations preforming on them.





(c)     whether a household’s accommodation has central heating or not,
data type: Boolean

reason: It is a yes or no question






(d)     the average number of cars owned by the households.
         data type: floating point

reason: Average may not be an whole number



Q3.
Convert the denary value 61 into
(a)     binary= 111101
(b)     hexadecimal= 3D


Q4.
A computer program contains the following fragment:
Boolean: LY
Integer: Y
¼
LY := (Y mod 4 = 0)  AND ( NOT (Y mod 100 = 0) OR (Y mod 400 = 0) )
(The function A mod B returns the remainder when A is divided by B, eg. 11 mod 3 returns the value 2.)
(a)     What is meant by a Boolean variable? A variable with only two possible answers e.g true or false.


(b)     What value would be assigned to the variable LY, if the variable Y contains
(i)      1999?----


(ii)     2000?----
Q5.
How many bits make up one byte? 8






Q6.
Using a High Level Language with which you are familiar, give one example of each of the following.
(a)     Data assignment. A=b+c
 (b)    Selection (Conditional step) If A=8 Then "Good"
 (c)    Repetition (Iteration) If A<8 then A=A+1





Q7. 
(a)     A binary pattern might represent a decimal integer or a decimal real number.  In a computing context, give an example of
(i)      a decimal integer= 65
(ii)     a decimal real number= 34.5656


Daily Dose Practice Exam questions

Q1. 

(a)     Explain the difference between hardware and software.
Hardware is the physical components parts of the computer. Example of a piecie of hardware is the computer motherboard.
Software is the program and code or instructions that the computer is given to use.

(b)     (i)      Which of the following is a typical value for the clock speed of a processor?
512 MB         128 kbps              80 GB           2 Mb/s             3.0 GHz
(circle your answer)
(ii)     Which of the following is a typical value for the capacity of a memory card for use with a digital camera or other device?
512 MB         256 bits/sec         50 GB           2 bytes            3.0 GHz
(circle your answer)
Q2.
A program has been written to analyse the results of a survey.  For each of the following, name a suitable data type and give a reason for your choice:
(a)     number of cars owned by a household;
data type: Integer
reason: Dealing with whole numbers only




(b)     a telephone number such as 0122456789;
data type: String
reason: So leading zeros do not dissapear and because it will not need calculations preforming on them.




(c)     whether a household’s accommodation has central heating or not,
data type: Boolean

reason: It is a yes or no question





(d)     the average number of cars owned by the households.
         data type: floating point

reason: Average may not be an whole number


Q3.
Convert the denary value 61 into
(a)     binary= 111101
(b)     hexadecimal= 3D


Q4.
A computer program contains the following fragment:
Boolean: LY
Integer: Y
¼
LY := (Y mod 4 = 0)  AND ( NOT (Y mod 100 = 0) OR (Y mod 400 = 0) )
(The function A mod B returns the remainder when A is divided by B, eg. 11 mod 3 returns the value 2.)
(a)     What is meant by a Boolean variable? A variable with only two possible answers e.g true or false.


(b)     What value would be assigned to the variable LY, if the variable Y contains
(i)      1999?----


(ii)     2000?----
Q5.
How many bits make up one byte? 8





Q6.
Using a High Level Language with which you are familiar, give one example of each of the following.
(a)     Data assignment. A=b+c
 (b)    Selection (Conditional step) If A=8 Then "Good"
 (c)    Repetition (Iteration) If A<8 then A=A+1




Q7. 
(a)     A binary pattern might represent a decimal integer or a decimal real number.  In a computing context, give an example of
(i)      a decimal integer= 65
(ii)     a decimal real number= 34.5656


Parity Bits


A parity bit is a single bit added to a binary data transmission used to indicate if whether the 0's and 1's within that data transmission is an even or odd number. The parity bit is used in parity error checking to find errors that may occur during data transmission.

Even parity can be more clearly explained by means of an example. Consider the transmitted message 1010001, which has three ones in it. This is turned into even parity by adding a one, making the sequence 1 1010001, so that there are four ones (an even number). If the transmitted message has the form 1101001, which is already an even number, a zero is added to sustain the even parity. The resulting message is 0 1101001, so that an even number of ones remains in the transmitted message.
Image result for parity bitImage result for parity bit
Even parity checking is also used in testing memory storage devices. However, in order for this to work, the sender and receiver should agree to use even parity checking as the basic error detection technique. If a single bit is switched during transmission, parity checks can detect that the data is corrupted. However, even parity may fail to detect errors introduced when an even number of bits in the same data unit is altered due to electrical noises.

Parity checking is the most basic form of error detection in communications. Although it detects many errors, it is not foolproof, because it cannot detect situations in which an even number of bits in the same data unit are changed due to electrical noise. There are many other more sophisticated protocols for ensuring transmission accuracy.
Parity checking is used not only in communications but also to test memory storage devices. Many PCs, for example, perform a parity check on memory every time a byte of data is read.