This action might not be possible to undo. Are you sure you want to continue?
Engr. J. Cansino
Information Technology Department
FEU – EAST ASIA COLLEGE
Program Elements & Structure
Program Elements and Structure
1.) Constants – Literal Value that does not change during program execution. It can be of the numeric or string type.
Numeric Constant - may be an integer (whole number) or a real number (with a decimal place). It may be preceded by a positive or negative sign. Examples: 10
Note: No other characters must or can appear together with the constants. The following are examples of incorrect numeric constants: 10,000 $14.3 10mi/hr 1/2
String Constant – A character or group of characters enclosed in double quotation marks ( “ ). The numbers 0-9, letters a-z or A-Z and all special characters like a space, % $ - _ & etc. may be included. Examples: “J” “Jojo” “.” “1225” “J & J”
Note: The entire string constant must always be enclosed in double quotation marks, one before the first character and one after the last character (no more no less). The following are examples of incorrect string constants:
“Earl Jerald Cansino” “SMART” “Avenger Assemble”
2. . The value stored in the variable must be given a unique variable name but it can only hold one value at a given time.) Must be unique that is. e. c. Variable names must conform to the following requirements: a.) Must contain only letters. numbers and/or an underscore. not a name of another variable.) Must end either with a letter or a number. WHILE and the like.) Variables – Is a portion of the computer’s main memory used to store a numeric or string constant.) Must begin with a letter. b.) Must not be a keyword like ACCEPT. d.
For example the variable TOTAL is the same as total. Array Note: Variable names are not case sensitive in flowcharting and pseudo-coding. String. The following are example of incorrect variable name: Year code 10ctr #5 Total= .A variable may be one of the following types: Numeric. that is. upper and lower case letters are not differentiated.
) Expressions – is a group of program elements consisting of operands and operators.3.) * / % 3. relational and/or string. Expressions always yield a value of a certain type depending on the type of expressions used. Operands can be a constant. and or an array element.) + - .) Expressions in parenthesis 2. logical. Operators can be arithmetic. variable. Arithmetic Expressions Hierarchy or Priority of Operators 1.
) 20 / 4 * 9 5 45 32 42 2.Examples: 1.) 10 + 4 * 8 3.) 50 % 6 – 5 2 -3 .
) “3” + “4” = “34” “Ja ” + “red” = ”Jared” Examples of incorrect usage of the + operator: “3” + 4 100 + “Peso” .String Expressions Examples: 1.) 2.
Relational Expressions Greater than Less than Greater than or equal to Less than or equal to Not equal Is equal to Examples: Ctr1 > 10 3 <= 5 Temp1 != Temp2 > < >= <= != == Examples of incorrect Relational Expressions: 30 <= X <= 40 43 > < 50 .
) 3.) Expressions in parenthesis Not (!) And (&&) Or (||) TRUTH TABLE FOR NOT(!) X FALSE TRUE !X TRUE FALSE .Logical Expressions Hierarchy or Priority of Operators 1.) 4.) 2.
TRUTH TABLE FOR AND(&&) X FALSE FALSE TRUE TRUE Y FALSE TRUE FALSE TRUE X && Y FALSE FALSE FALSE TRUE TRUTH TABLE FOR OR(||) X FALSE FALSE TRUE TRUE Y FALSE TRUE FALSE TRUE X || Y FALSE TRUE TRUE TRUE .
) 3.) 2.) 5.) DISPLAY Statement ACCEPT Statement IF Statement WHILE Statement FOR Statement .Examples: 15 >= 10 && 15 <= 20 T && T T 4. which perform which perform a predefined procedure.) 4.) Statements – are keywords. The following statements are available: 1.
) 8.Assignment #1.) 2.) 7.) 9.) 3.) 10. 1.) 4.) 11 % 2 + 3 * 7 –2 100 % 5 % 3 % 2 – (45 / 9) * 6 + 4 (5 + 7) % (10 * 2 – 5) / (15 – (8 – 6 % 4)) (8 + 21 % (18 – 5 * 3)) % (17 – (6 + 13 % 5)) (12 == 12 % 2 * 2) && !(( 5 > 3) && (8<3)) (6 > 3) && (8 != 8) || !(10 <= 10) 15 / 3 == 15 % 3 5 != 11 / 2 (100 * 24)/12 + 45 .) 6.1 Evaluate the following expression.) 5.
Variable Name: 8.000. (10 / 3 + (16 + 3) )– ((5 * 2 % 10) + 2) 3. (T || F) && (!(!F && (6 > 8) || (5< 10) || F) || !T) 4. Variable Name: 5.9)%(5*2%3) _J_A_R_E_D (5<=2*2) =10+1 (!(!(!(F&&T)))) J5R3D “*&****hello##” 1. Numeric Constant: 2. Logical Expression: 7.12345” HELLO_TRISHA (45. String Constant: 3. Arithmetic Expression: 4. (T || !F) || (!(!(!F || (3 < 15) || F) || !F) && T) 5. 12 % 6 + (2 + 12 * 3) – ( 12 % 13) 2.000. Numeric Constant: 10.Assignment #1. Logical Expression: “0.98 (!T&&!F)||(!F) Evaluate the Following expressions: 1. !(!T && !F) || (!T || (12 <= 12) || (T && F)|| F) . Relational Expression: 6. String Constant: 9.2 Check if Valid (V) or Invalid (I) 1.
.A diagram of a sequence of steps that a program must perform to produce the desired output.FLOWCHARTS .) System Flowchart – present the total picture without worrying about taking care of every detail.A graphic form of an algorithm.) Program Flowcharts – depicts a main segment of a complete computer program. . . 2. flexibility TYPES OF FLOWCHARTS 1.Traditional tool of programmers which allow in terms of detail to be included.
2.) Do not crisscross flowlines (used labeled connectors and use arrowheads to indicate direction of the flow.) Construct your flowcharts to read from top to bottom and left to right.) Make the messages and labels in the flowchart symbol direct and descriptive. 3. 4.) Strive for neatness. clarity and simplicity.FLOWCHARTING GUIDELINES 1. 5.) Always use the ANSI standard symbols. .
BASIC FLOWCHARTING SYMBOLS Terminal Symbol Preparation Symbol Processing Symbol Decision Symbol .
Input/Output Symbol Predefined Process Symbol Onpage Connector Offpage Connector Flow Direction Lines .
Sequential Program Structure .
For Flowchart. symbols used are the following: Terminal symbol I/O symbol Preparation symbol Direction lines .
For Pseudocode.) Accept Syntax: Accept <variable> Accept <variable1>.) Display Syntax: Display “<string>” Display <variable> Display <variable1>. …. <variableN> 2. …. keywords used are the following: 1. <variableN> .
The formula is a follows: Fahrenheit = 9 (Celsius) + 32 5 .Sequential structure #1] Input a temperature in Celsius and output the corresponding temperature in Fahrenheit.
0/5. C are numeric F=0 Input C Begin F=0 Display ” Input temperature in Celsius: ” F = (9.0) * C + 32 Accept C F = (9.0) * C + 32 Display “Equivalent temperature in Fahrenheit:”.0 / 5. F End Output F End .Pseudocode Flowchart Start Variables Used: F.
.Sequential structure #2] Pepperoni++ Pizza House charges 10% service charge and 5% sales tax on the gross bill of the customer. Create a flowchart and a pseudocode that would input the gross bill of the customer and the amount given by the customer to the waiter. It must output the customer’s total bill and change (if there’s any).
05 change = Amt . Tbill Display “Change = ”. Amt. change End .1 + Gbill * 0.TBill Display “Total Bill = ”.05 Output TBill. change End change = Amt .Flowchart Start Variables Used: Pseudocode GBill.TBill Accept GBill. TBill are numeric TBill = 0 change = 0 Input GBill. Amt Begin TBill = 0 change = 0 Display ” Input Gross Bill and Amount Given: ” TBill = Gbill + Gbill *0. change.1 + GBill * 0. Amt TBill = GBill + GBill * 0.
Moreover. the increase was retroactive for 2 months. . that is.5% salary increase.2: Sequential structure #5] Using Visual Logic.Assignment #1. Create a flowchart and a pseudocode that takes the employee’s old salary as input and then output the amount of retroactive pay (balance) due the employee and his new salary as well. effective two months ago. Draw and execute a FCD for Workers at a particular company were given a 15.
SELECTION / CONDITIONAL PROGRAM STRUCTURE .
symbols used are the following: Terminal symbol I/O symbol Preparation symbol Flow Direction lines Decision symbol .For Flowchart.
keywords used are the following: 1. <variableN> 2.For Pseudocode. ….) Accept Syntax: Accept <variable> Accept <variable1>. …. <variableN> .) Display Syntax: Display “<string>” Display <variable> Display <variable1>.
3. . . end Syntax #1: if <condition> then else begin statements . end . .) if-then-else begin statements . .
Syntax #2: if <condition1> then begin statements end else if <condition2> then begin statements end else if <conditionN> then begin statements end else begin statements end .
Selection/Conditional Structure #1] Using Visual Logic. . create a flowchart and a pseudo-code that will prompt the user to input two number and output the highest number entered.
Flowchart Start Input N1. N2 Y If N1 > N2 N Output N2 A End Output N1 A .
N2 if (N1 > N2) then Display N1 else Display N2 End .Pseudocode Variables Used: N1. N2 are numeric Begin Display ” Input two numbers: ” Accept N1.
paper (code P). or stone (code S). If one chooses paper and the other stone then paper wins.00 Create a flowchart and a pseudocode to input the car’s speed and then output the fine. #2] In the game of JACK N POY each of the two player choose either a scissors (code X).00 76 mph and above = Php 4000. If they both choose the same then the result is a tie. Create a flowchart or a pseudocode that will input two character codes corresponding to the object selected and then output either the message “PLAYER 1 WINS” or “PLAYER 2 WINS” .Assignment # 1 . as follows: 60 to 75 mph = Php 2000. if any. If one chooses paper and the other scissors then scissors wins.3 Selection Structure #1] The fine for an over-speeding violation depends on the speed of the erring driver. If one chooses scissors and the other chooses stone then stone wins.
whichever is higher. gives additional performance bonuses to its employees every year. .#3] Bongga Ka Day Inc.000. The amount is dependent on the number of years of service of the employee as follows: Years of Service Amount of Bonus 5 years and below 6 years to 10 years 11 years to 25 years 50% of monthly salary 100% of monthly salary Php 30.00 or twice the monthly salary.
ITERATIVE/ LOOPING PROGRAM STRUCTURE .
For Flowchart. symbols used are the following: Terminal symbol I/O symbol Preparation symbol Flow Direction lines Decision symbol .
) Display 3. if-then-else 4. . end . .) if-then. .) Accept 2.For Pseudo code.) while-do Syntax: while <condition> do begin statements. keywords used are the following: 1.
20. 8. 7.Iterative Program Structure #1] Create a flowchart/pseudo code that will generate the following number series: 10. 5. 6. 10. 15. 9. and 25 .
Y X=X–1 Y=Y+5 Y N End If X >= 6 .Start Flowchart X = 10 Y=5 Output X.
Y X=X–1 Y=Y+5 end End . Y are numeric Begin X = 10 Y=5 while (X >= 6) do begin Display X.Pseudo code Variables Used: X.
21. 8. 3. 34. 1. 5. 13. and 55 .Iterative Program Structure #2] Create a flowchart/pseudo code that will generate the following number series: 1. 2.
Start X=0 Y=1 Sum = 1 Flowchart Output Sum Sum = X + Y X=Y Y = Sum Y If Sum <= 55 N End .
Sum are numeric Begin X=0 Y=1 Sum = 1 while (Sum <= 55) do begin Display Sum Sum = X + Y X=Y Y = Sum end End .Pseudo code Variables Used: X. Y.
#2] Create a flowchart/pseudo code that will input five numbers and output how many of the numbers entered are positive or negative. .Assignment #1.4 Iterative Program Structure Using Visual Logic: #1] Create a flowchart/pseudo code that will input five numbers and output how many of the numbers entered are odd or even.
Assignment #1. Create a flowchart/pseudo code that will input 5 numbers and output the highest number entered. Disregard characters that are not alphabetic. #4] #5] . Eliminate the lowest quiz and compute and output the average of the five remaining quizzes. Create a flowchart/pseudo code that will input 6 score for quizzes (0-100).3 Iterative Program Structure #3] Create a flowchart/pseudo code that will input 10 alphabetic characters and output how many of the characters entered were vowels and consonants.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.