0% found this document useful (1 vote)
93 views5 pages

CMAM401 Handout1

Computer system components: 1) Input 2) process 3) Output Blue print - the logic and ideas transformed into a map of how a computer should do things. Programmers write computer instructions in computer programming language. When ideas are converted into a computer program, it is sent to the CPU for processing. But the CPU cannot understand the code (computer program) and will not do anything because of language incompatibility.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
93 views5 pages

CMAM401 Handout1

Computer system components: 1) Input 2) process 3) Output Blue print - the logic and ideas transformed into a map of how a computer should do things. Programmers write computer instructions in computer programming language. When ideas are converted into a computer program, it is sent to the CPU for processing. But the CPU cannot understand the code (computer program) and will not do anything because of language incompatibility.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

CMAM 401 INTRODUCTION, BASIC SYMBOLS AND VARIABLES Computer an electronic device that can accept, process and

d store vast amount of data to produce useful information. Computer system components: 1) Input 2) Process 3) Output Blue print the logic and ideas transformed into a map of how computer should do things; It serves as the basis of how a computer functions, and how data are processed inside the computer. It is implemented through software (instructions that tells the computer what to do) and executed through the interaction of different hardware devices (physical computer itself). Relationship of the components of a computer system (Blue print): Input Process Output Behind the scene in action Computer programmers write computer instructions in computer programming language. Just as people speak their native dialect, programmers write programs in different languages (ex. C++, Visual Basic, Java and COBOL). No matter which programming language the computer programmer uses, the language has rules governing its terminology and punctuation. These rules are called the language syntax. Syntax language. a rule that governs a programming

Note: Every programming language is unique and has their specific set of syntax.

When ideas are converted into a computer program, it is sent to the CPU for processing. However, the CPU cannot understand the code (computer program) and will not do anything because of language incompatibility. For the CPU to understand the code, a language translator is needed. Compiler (Interpreter) the language translator software; its role is to transform the code into a machine language (series of 1s and 0s to represent ON and OFF states of the computer devices. It is also the representation of the digital electronic charges inside the computer). Once the code is compiled, it changes its form from computer program with strict syntax to a readable machine language that can be interpreted by the CPU. CPU then executes the instructions and performs tasks. Computer program (code) the lifeblood of a computer system; it is a fluid that runs through the veins of the computer that tells what organ to function and what action to perform. It is a set of logical instructions given to a computer for data processing that is interpreted by a compiler to produce used information. Guide questions in planning and developing a program: 1) What is the problem? 2) What are the available data? 3) What output information or data is needed? 4) When do you need the output? 5) What processing is needed to produce the output? 6) What is the desired output? 7) Where should the output go? Flowchart a modeling tool used to illustrate data, instructions, process, information and workflow by the use of specialized symbols. It is a step-by-step graphical representation of a solution.

Data in computer system, it refers to numbers, alphabets and alphanumeric characters. Central Processing Unit (CPU) a tiny square piece of integrated circuit attached on the mother board that normally has a dimension of 1 x 1, though small in size, its functions in the computer system is enormous. It is the brain of the computer. Components of a Central Processing Unit: 1. Control unit (C.U.) the command center of the processor. Three primary functions of a control unit: a. read and interpret instructions b. direct flow of operations of computer and hardware devices c. control the flow of instructions and data

2.

Register a temporary storage microchip that holds data during processing; located inside the CPU and has the same function that of a memory, specifically the type Random Access Memory (R.A.M.) because of its volatile character data are lost once electric current is turned off; it just holds data temporarily for processing.

3.

Arithmetic and Logic Unit (A.L.U) the most significant component inside the CPU. It is the chief of operations of the computer. Two major operations of Arithmetic and Logic Unit: a. Mathematical operations (addition, subtraction, multiplication and division) b. Logical operations (comparisons of data such as; greater than, less than, greater than or equal to, and less than or equal to)

CMAM401- HANDOUT

PAGE 1

Basic flowchart symbols: Symbol Name Terminal (interrupt)

Other flowchart symbols: Symbol Name Description Defines the starting and ending point of a flow chart The preparation (initialization) of memory space for data processing The inputting of data for processing, and the printing out of processed data Manipulation of data (assignments and mathematical computations) Defines the logical sequence of the program. It points to the next symbol to be performed Connects to the flowchart to avoid spaghetti connection on the same page Connects the flowchart on different page to avoid spaghetti connection Process conditions using relational operators. Used for trapping and filtering data Display Manual operation

Definition Denotes a manual operation or one which requires an operator An input or output medium or a means of secondary storage A printed document or report. It is used to show either input or output Represents terminals used as input Represents data stored on punched paper tape. May be either input or output It is connected directly to computer and represents such devices as disks and drums Output information is display on CRTs, terminals, plotters, etc An input of data on cards or an output of information on cards

Initialization (pre-defined process)

Magnetic Tape

Input/Output

Document

Process (logical process)

On-line keyboard

Punched tape Flow lines

On-line storage

On-page connector

Off-page connector

Punched card

no

yes

Decision

Variables a primary storage location that can assume different numeric or alphanumeric values. It is also a memory space allocated by a computer user for processing and storing data
Variables like humans need names to be identified. Microsoft suggests a variable naming convention called HUNGARIAN NOTATION.

Hungarian Notation specifies a variable with both the data type and its description. The first three characters in this notation specify the data type and the remaining characters are the description of the variable.

CMAM401- HANDOUT

PAGE 2

Basic data types Date type Description *integer Whole number **float double *character *string *boolean or Integer with decimal numbers Alphabets and special characters Combination of characters

Sample 10 355 1590 54765 1 34000 3.1416 0.12 1.01 12.12 99.99 0.04 J W A * & ? Sum age int_l A_total grand_total

Operation Multiplicati on

Symbol *

Sample A*B

Division

X/Y

Reply of the compiler in the Values are program that is either 1 for YES performed or 0 for NO behind the scene *used mostly by all programming languages **C/C++, Java, Visual Basic and other programming languages specific ***Note that the data types above are not the only data types used in programming. Other programming language may have their own set of data types with specific descriptions that are not presented above.

Addition

Int1+int2

Subtractio n Exponentia tion Greater than

A-B

C^2

>

a>b

Sample variable names using Hungarian Notation Variable name Data type Description IntSum Integer Sum DblTax Double Tax FltRate Float Rate ChrReply Character Reply StrLname String Lname BooAns Boolean Ans Variable name characteristics: 1. Must be descriptive and significant to the data, problem and its solution. It should be descriptive enough to identify the process or data referring to 2. Combinations of alphanumeric characters (alphabet, numbers and special characters) can be used as a variable name provided that it starts with an alphabet 3. Although the length of variable name can have 256 characters, the lesser the number of characters the more efficient the program is Examples: Class_size Tuition Int1 Income Sum Char3 F_name Answer Net income L_name Total Grand_total Computer Operators: Processing data The languages of computers need to be converted to a language that the CPU can understand. For the programmer to instruct computers to process mathematical computations and logical operations, they would have to define symbols that computers can understand. The symbols presented are the generic symbols used by computers for processing. However, as you progress to the different programming languages, the mathematical and relational symbols may vary.

Less than

<

X<Y

Equal to

==

Int1 = = int2

Not to

equal

<>

Net <>Gross

Greater than or equal to

>=

Pay1>=Pay2

Less than or equal to

<=

Age1 <= Age2

Explanation Multiply the value of variable A to the value of variable B Divide the value of variable X by the value of variable Y Add the value of variable int1 to the value of int2 Subtract the value of variable B from the value of variable A Square the value of variable C The value of variable a is greater than the value of variable b The value of variable X is less than the value of variable Y The value of variable int1 is equal to the value of variable int2 The value of variable net is not equal to the value of variable gross The value of variable pay1 is greater than or equal to the value of variable pay2 The value of the variable age1 is less than or equal to the value of variable age 2

Exercises: Convert the following mathematical expression to its computer expression: Mathematical expression 1) 3xy 2) x2 + y2 Computer expression 3*x*y (x*x) + (y*y) Or x^2 + y^2 (3*x)/(y*y*y) or

3) Arithmetic operators

3x Y3

CMAM401- HANDOUT

PAGE 3

(3*x)/(y^3) 4) a2 + b2 cd [(a*a)+(b*b)]/(c*d) or (a^2 + b^2) /(c*d)

3. Create a flowchart that will move the value of A to B and B to C. The values of the variables are: A=25; B=30 and C = 35 4. Create a flowchart that will arrange the values of A, B and C in ascending order where variable A will get the lowest value and variable C gets the highest value. The values of the variables are: A=15; B=10 and C=20 5. Create a flowchart that will arrange the values of A,B,C and D in highest to lowest order where variable A gets the highest value and variable D gets the lowest value. The values of the variables are: A=3; B=9; C=12 and D=6 INPUT/OUTPUT AND PROCESS APPLICATION Input the only way for the user to send data to the computer for processing. It can be numeric value, character or string. When the computer executes input transaction, it expects data to be entered through the keyboard. If none is typed in, the computer simply waits for an input data, if no data was entered, the computer just wait for the user and gives no response. To prevent this scenario, programmers must develop the program in a way that it can communicate to the user. For the program to communicate, it must have a descriptive statement to ask the user what to do and what type of data to input. In the same manner, the output should also include a descriptive statement to communicate to the user the processed data to add meaning and value to it, and making it a useful information. Output instruction defines when and where to release the data in the program. Sample instruction: Input an integer value 5 to variable A and print the value Input instruction using flowchart symbol: 5
Input (A) 0

Types of variables The role of variables in programming is very crucial. In the processing stage of a program, the variables hold the data and information (whether it will be stored in the memory or used for computation or printing processed data). The challenging part in this stage is identifying who gets the processed data? This can be clarified by the descriptions of the types of variables:

Destructive variable variables that destroy or change its value after processing. This type of variable is normally the temporary storage of data during processing

Constructive variable variables that maintains its value after being used in the process. Exercise: Suppose we have variables A and B and the values of A and B are 5 and 10, respectively. What will happen if we have an instruction of A=B? Working with process symbols Basic things to remember in flowcharting: 1. A flowchart always start with the instruction START/BEGIN the only guideline to remember in the terminal symbol is the consistency of terminologies. The organized way of writing the instruction is to use pairs. STARTSTOP or BEGIN-END 2. Initialization symbol is where you prepare the variables to be available for use. When you initialize, you are also allocating memory space for your data storage. As a rule, we always draw this symbol to state the use of our memory 3. The processing symbol is only LIMITED to; assignment of new value to the variables and mathematical computations 4. Since we use START in the opening of our flowchart, for consistency, we should use STOP to terminate

start

A It is assumed that Integer A was initialized to 0 to allocate memory space. Executing the instruction, integer 5 is stored to variable A destroying the initialized value 0. Take note that the value was defined in the problem and in most cases the user defines input values.

stop

EXERCISES: 1. Create a flowchart that will store the value of A to B, where A = 5 2. Create a flowchart that will assign stored value of C to both A and B, where A=15, B=10 and C=20

Output instruction using flowchart symbol:

5
Print (A) 5

CMAM401- HANDOUT

PAGE 4

A If the Input symbol uses INPUT to accept data, the output symbol uses PRINT to sent out data, whether the output data will be taken as an input to another process or literally printed, the instruction that will be use to send out data is Print. In the instruction, integer 5 is sent out from variable A. Since we are sending out a number, we simply say PRINT(VARIABLE NAME), in case we are to send multiple data we say:

C = A+B

10

A + B = C The illustration clearly shows that the values of the variables were added and stored to variable C. if we would like to print the sum after processing we simply use the Output symbol as shown below:

Print (C)

4
A

6
B

10
C

Print(C,B,A)

6
A

4
B

2
C

10

2, 4, 6

Exercises: 1. Create a flowchart that will accept two integers and print the sum 2. Create a flowchart that will accept a value for radius and compute and print for the area of the circle, where the formula for area is: Area = r2 ; the value of (Pi) is 3.1416

In this illustration, we can clearly see that the programmer defines the organization of the variables in sending out data by setting the order of variables in the Print instruction as shown. As long as the programmer knows the value of the variables, the programmer can use his/her creativity in presenting output and in meeting output requirements.

3.

Create a flowchart that will accept the length of the base and height of a triangle and print the area. The formula for computing the area of the triangle is: Area = b*h; where b is the base and h is the height Create a flowchart that will accept a temperature in Fahrenheit and print its equivalent temperature in Celsius. The formula for converting Fahrenheit to Celsius is C=5/9 (F-32); where F is the temperature in Fahrenheit END OF LECTURE

Learning Exercise1: Create a flowchart that will accept two integers and print the inputted values.

4.

Examining the flowchart: To check if the solution meets the requirement before it is written to actual code, programmer use a technique called SIMULATION. Simulation a process of executing the flowchart in a step-by-step manner showing all the variables used the execution of all instructions, and the output on each step.

Learning Exercise2: Create a simulation of learning exercise1.

Process Process symbol is the only area in the program where all arithmetic computations take place. Aside from the mathematical computation, it can also perform an assignment. This occurs when a variable needs to accept new data to meet the required solution. Sample instruction: Perform C=A+B where A=4 and B=6 The mathematical formula given tells us to add the values of the variables A and B to store the sum to variable C. Process instruction using flowchart symbol: ADD

CMAM401- HANDOUT

PAGE 5

You might also like