Itec 102 Reviewer
Itec 102 Reviewer
Itec 102 Reviewer
WHAT IS AN ALGORITHM?
An Algorithm is a set of instructions for solving problem, step-by-step. Typically, algorithm are
executed by computers and should contain an INPUT, PROCESS and an OUTPUT.
An Algorithm is a “finite set of precise instructions for performing a computation or for solving a
problem”
Examples:
A program is one type of algorithm
A direction to somebody’s house is an algorithm
A recipe for cooking a cake is an algorithm
The steps to compute the cosine of 90 degree is an algorithm
VARIABLES
MATHEMATICS- A Letter than can represent any number
A=4+b
PROGRAMMING- A Letter / Word that serves as a temporary storage that can
represent any value
Programming Problem
Create a Program that will display the sum of 2 number inputted by the user.
Algorithm:
1. Declare 3 Variables,
2 Addends
1 for the Sum
2. Let the user input the addends
3. Perform the addition between the addends and assign it to the sum
4. Display the sum
FLOWCHART
WHAT IS A FLOWCHART?
A method that allows a programmer to represent the Algorithm in a diagram or an
illustration.
Flowchart vs Pseudocode
Flowchart- Graphically depicts the logical steps to carry out a task and shows how the
steps relate to each other.
Pseudocode- Uses English-like phrases with some Visual Basic terms to outline the
program.
PSEUDOCODE
USES OF PSEUDOCODE
1. To help non-programmers understand what is happening or what is the process of the
program.
2. Solving logic error and debug computer program for the programmers.
DATA TYPES, VARIABLES AND CONSTANT
Data types, Variables and Constant
C# is a strongly typed language. It means, that you cannot use variable without data
types. Data types tell the compiler that which type of data is used for processing. Such as if
you want to work with string value then you will have to assign string type variable to work
with. C# provides two types of data types: Value types and Reference types.
A Value type data type stores copy of the value whereas the Reference type data
types stores the address of the value. C# provides great range of predefined data types but it
also gives the way to create user defined data types.
WHAT IS VARIABLE?
A variable refers to the memory address. When you create variable, it creates holds
space in the memory that is used for storing temporary data. As you know about c# data
types, each data type has predefined size.
ATTRIBUTES OF A VARIABLE
A variable has;
Name
Address
Datatype
Value
DECLARING VARIABLE
<datatype> varname = value;
string firstName;
string lastName=”Origines”;
int num = 0, num2=0;
Conversion
C# accepts string value by default. If you are using other value then you will have to convert
of specific data types.
num1 = Convert.ToInt32(Console.ReadLine());
C# OPERATORS
C# PROGRAMMING OPERATORS
Operators are used for building expressions in C#. To calculate the value of a
variable or performs the operation in the variable you will have to make a proper expression.
These expressions are made using C# operators.
ARITHMETIC OPERATOR
Operators are a very useful thing in computing value. While writing a program, you
need various types of operators to calculate the value. These operators are categorized as
different categories in C sharp tutorial that performs specific task ex. The C# arithmetic
operator performs the basic calculation as add, subtraction, multiplication, division, and
modulus whereas other operators perform a different kind of task.
In this example, the equal to (=) assignment operator assigns the value of num1 +
num2 into result variable.
UNARY OPERATOR
The C# unary operator is widely used for increment or decrement value by 1. This
operator is widely used with loop constructs to increment loop by 1. It is very easy to use and
understand C# unary operators.
UNARY OPERATOR
++ INCREMENT OPERATOR:
This operator is pronounced as increment operator. It is used for incrementing value
by 1. It is used in C# programming by two types: Pre-increment (++i) and Post-increment (i+
+). In pre-increment, first it increments by 1 then loop executes whereas in Post-increment,
the loop executes then it increments by 1.
-- DECREMENT OPERATOR:
The behavior of decrement operator is just opposite from increment operator. It is
used for decrementing the value by one. It has also two types: Pre-Decrement (--i) and Post
Decrement (i--). In pre-decrement the value is decremented by one then loop executes
whereas in post-decrement the loop executed then the value decrements by one.
COMPARISON OPERATOR
The C# comparison operator is used to compare two operands. It returns true or false
based on the comparison.
LOGICAL OPERATOR
The C# Logical Operator also evaluates the values and returns true or false as output.
Based on true-false the program behaves dynamically at runtime. This operator is widely used
with C# programming.
LOGICAL OPERATOR
“And” Logical Operator (&&)
&& Operator is pronounced as “and” operator. It returns true if both or all the
conditions are true and return false if any of the condition is false.