Professional Documents
Culture Documents
1 Programing Flowchart
1 Programing Flowchart
Enter values
for A and B
Input value
for
Fahrenheit
Print
Celsius = (5/9) * (F-32) Celsius End
Operators Commonly
Used in Flowcharting
Arithmetic Operators
Operators Meaning
+ Addition
- Subtraction
* Multiplication
/ Division
Relational Operators
= Equal
> Greater than
< Lesser than
!= Not equal
> Greater than or Equal to
< Less than or Equal to
Logical Operators
&& AND
II OR
! NOT
• DEI Manufacturing Company plans to give a year-
end bonus to each of its employee. Draw a
flowchart which will compute the bonus of an
employee. Consider the following conditions:
If the employee’s monthly salary is less than
2,000 pesos, the bonus is 50% of the salary; for
employees with salaries greater than 2,000
pesos, the bonus is 1,500 pesos.
Print the name and the corresponding bonus for
each employee. Write each equivalent
algorithms.
START Algorithm:
Step 1. Initialize bonus to 0.
Step 2. Read in employee’s name and
Bonus = 0 salary.
Step 3. Test if employee’s salary is less
than 2,000..
Enter Name, Step 4. If salary < 2,000 then
Salary Bonus = salary * 50%
else
Bonus = 1,500
Salary
< Step 5. Print the
Bonus = 1,500 employee’s name
2,000
and bonus.
Print Name,
Bonus END
Start
Bonus = 0
Read Name,
Salary
Salary
<
Bonus = 1,500
2,000
A
Bonus = 0.50 * Salary
Print Name,
Bonus End
Looping
• Do – while –
This structure provides for the repetitive
execution of an operation or routine while
the condition is evaluated before executing
any process statement. As long as the
condition is true, the process is executed,
otherwise, control flows out of the
structure.
F
C
A
• Construct a flowchart that will count from 1 to
10 and print each number counted using the do-
while-repetition structure. Write its equivalent
algorithm. Start
C=0
C End
Algorithm:
Step 1. Initialize the value of C to 0.
C=C+1 Step 2. Test if C is less than 10.
Step 3. If C is less than 10, add 1 to the
value of C, print the value then go
Print C
back to Step 2. However, if C is
greater than 10, stop processing.
Exercise problem.
Construct a flowchart that will accept the evaluation score
of a faculty and determine its equivalent remarks. Print
the name of the faculty and the remarks obtained.
Remarks(rem) are based on the following criteria: Write
its equivalent algorithms.
4.50 – 5.00 – Outstanding
4.00 – 4.49 – Very Satisfactory
3.50 – 3.99 – Satisfactory
3.00 – 3.49 – Needs Improvement
2.99 below - Poor
Overview of Turbo C Language
History of C Language
B was developed in the year 1970 by Ken
Thompson
To augment B’s power Dennis Ritchie invented
and first implemented the C prog. Language at
Bell Laboratories.
Originally developed under UNIX environment
and became popular 6 years after
Often called a middle –level language.
Continuation…
Input, output commands, and special words
are often referred to as reserved words and
are written in lower case only.
C is case sensitive
C was initially used for system development
work, programs that make up the operating
system.
Data Types
5 elementary data types
Type Bit width Range
char 8 0 to 255
int 16 -32768 to 32767
float 32 3.41E-38 TO 3.4E+38
double 64 1.7E-308 TO 1.7E+308
void 0 valueless
Type modifier
Signed, unsigned, long, short
Keywords
Keywords in C are reserved words that have a
special meaning. Reserved words are words
“reserved” by the programming language for
expressing various statements and constructs,
thus, these may not be redefined by the
programmer.
List of 32 Keywords / Reserved words as
defined by the ANSI standard
auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while
VARIABLES,
CONSTANTS,
OPERATORS, AND
EXPRESSIONS
Identifiers Defined
Identifiers are composed of a sequence
of letters, digits and the special character _
(underscore). Avoid using names that are too
short or too long. Limit the identifiers from 8
to 15 characters only.
Variables Defined
Variables are identifiers that can store a
changeable value. These can be different data
types.
Rules for defining or naming identifiers /
variables
1. It must consist only of letters, digits, and underscore.
Example: _duh, num_1 (correct)
Example: int i, j, k;
short i, j, k;
Note: *before declaring variable, specify, first
the data type variable/s
* variables must be separated by comma
* all declarations must be terminated by a
semicolon (;)
Two kinds of
variable
Local Variables
“Variables that are declared inside a function are called
local variables. It can only be referenced by statements that
are inside the block in which the variables are declared”.
Example:
#include <stdio.h>
main( )
{
int a, b, c; local variables
________;
________;
________;
}
Global Variables
“Global variables are known throughout the
entire program and may be used by any piece of
code. Global variables are created by declaring them
outside of any function”
Example :
#include <stdio.h>
int a,b,c; global variable
main()
{
;
;
;
}
Constants Defined
Constants are identifiers/variables that can store a
value that cannot be changed during program
execution.
II
true II true = true
OR true II false = true
false II true = true
false II false = false
! true = false
I ! false = true
C. Bitwise operator
“ Bitwise operations are the testing, setting or
shifting of the actual bits in a byte or a word, which
corresponds to C’s standard char and int data types
and variants. Bitwise operators cannot be used on
type float, double, long double, void or other more
complex types.”
Operator Action
& AND
I OR
^ Exclusive OR(XOR)
~ One’s complement
>> Shift right
<< Shift left
D. The ? Operator