1/90
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
5 types of Operators
• Assignment
• Arithmetic
• Relational
• Logical
• Special
is an syntactically correct
combinations of operands and operators.
Expression
They both have a TYPE and VALUE
Operators and Expressions
Two basic types of arithmetic operators:
Unary and Binary
An operator that only requires one operand
Unary Operator
An operator that requires two operands
Binary Operator
There are only arithmetic operator, and _ arithmetic operators.
1 unary, 5 binary
Rules which determine precisely how expressions are evaluated
Rules of Precedence and Associativity
Terms which are always evaluated first
Expressions within the Parenthesis ( )
In , all decimal portions of
numbers are lost (or truncated).
Integer Arithmetic
Evaluates an arithmetic expression consisting of an operator and two integer operands.
Integer Arithmetic
Characterized by : variable = expression
Assignment Operator
Basic operator in C
Equal sign (=)
Can be used more than once in an expression
Assignment Operator
An assumption on which tests the validity or effect
of something else
Condition
Are used to represent true or false because
there is no actual boolean or logical data type in C
Integers
An expression that is either true (represented by 1)
or false (represented by 0)
Condition
Are used to test specific conditions and requires the use of two operands
Relational Operator
Operators such as:
<
>
<=
=
Relational Operator
Relational Operators == and != are often referred to as-
Equality Operators
Connects two or more relational
expressions into one or reverse the logic of an
expression.
Logical Operators
represents a non-zero value (can be negative
or positive numbers, float, character, string)
True
represents a zero value (integer or float
value)
False
symbol used as an increment operator to increment or add 1 to the operand value
Double Plus Symbol (++)
value is first incremented and then used inside the expression
Pre-Increment Operator
value is first used in an expression and then incremented
Post-Increment Operator
increment and decrement operators are considered as _ since they require only one operand
Unary Operator
symbol used as an decrement operator to decrement or subtract 1 to the operand value
Double Minus Symbol (--)
value is first decremented and then used inside the expression
Pre-Decrement Operator
value if first used in an expression and then decremented
Post-Decrement Operator
operators used in special situations
Special Operator
5 types of special operator
Reference Operator
Dereference Operator
SizeOf Operator
Ternary Operator
Comma Operators
returns the address of the variable
Reference Operator
symbol used as a reference operator
&
returns the value of a variable
pointed by the specified pointer
Dereference Operator
symbol used as a dereference operator
*
used to determine or compute the operand's size in bytes
SizeOf Operator
the size of int data type in the TurboC application, as it is a 16-bit-based application
2 bytes
the size of int data type in today's compilers (e.g., MinGW GCC Compiler)
4 bytes
size of char data type
1 byte
size of float data type
4 bytes
size of double data type
8 bytes
helps on creating a short way of writing conditional statements
Ternary Operator
syntax of ternary operator
condition ? S1 (True) : S2 (False)
comma can be used as a ____ or as a ____
Separator, Operator
has the least precedence of all C operators
Comma Operator
returns the rightmost value of an expression but first evaluate the rest of the expressions and discard their values
Comma Operator
way of converting one datatype to another
Type Conversion
automatically done by the compiler
Implicit Type Conversion
in the implicit type conversion, datatypes in the expression will be converted into the datatype used within the expression
Largest
basic datatype upgrade sequence (least to greatest)
char -> int -> float -> double
specifies on which datatype to be converted
Explicit Type Conversion
explicit type conversion is also called as _
Type Casting
There are three (3) basic classifications of
statements in C, and actually, there are very few
statements of each type.
PROGRAM STATEMENTS
(3) basic classifications of
statements in C,
Primitives
Decisions
Loops
3 type of Primitive statements
Null Statement
Simple Statement
Compound Statement
( ; )
Null Statement
Simple Statement
Compound Statement
Conditional branches - make decision before branching:
and its 2 type
Decision Statements
Single-decision branch
Multi-decision branch
Single-decision branch - ____
Multi-decision branch
– switch/case
Decision statements are actually part of a larger category statements known as ??
branches
2 kinds of branch statements?
Conditional branches
Unconditional branches
involves making one or more decisions before branching, and are thus referred to as single-decision or multi-decision branches.
Conditional branches
direct branches which involve no decision. The goto statement is an example of an unconditional branch.
Unconditional branches
The___ statement is a conditional, single-decision branch.
if
The if statement has the general format of ?
if(expression) statement;
IF STATEMENTS may be a ____ statement or ___ statement.
simple
compound
it allows you to check between multiple test expressions and execute different statements.
IF ELSE IF STATEMENTS
a conditional, multi-decision branch. The previous example of successive comparison of equality or value of the operand is so common in programming, a special construct exist in C to handle such comparison.
SWITCH-CASE STATEMENTS
____ is evaluated and its value is compared.
Expression
The expression and the constant compared against must be an _ constants or expressions. They may NOT contain variables.
integer or character
The default case is optional, but if it exists there can be ____. It may occur anywhere in the list of case clauses but usually occur at the end
only one
One of the fundamental properties of a computer is its ability to repetitively execute a set of statements.
ITERATIVE STATEMENTS
These looping capabilities enable the programmer to develop concise programs containing repetitive processes that could otherwise require thousands of program statements to perform.
ITERATIVE STATEMENTS
C contains three looping constructs:
The while statement
The for statements
The do/while statements
The _ statements may be described as
test-before-execute. If the controlling condition
results initially to a zero or false value, the body
of the loop is never executed.
while and for
The ____statement on the other hand may be
considered as execute-before-test. The body of the
loop is always executed at least once.
do-while
The _is used to execute a statement as
long as a condition remains true.
with a syntax of
While (expression){
//statement
}
while loop
The conditional expression, of course, may be
a _ or ____.
relational or arithmetic
_ is usually used when the number of times the loop must be executed is not known in advance.
while loop
The ____ is generally used for counted
loops.
for statement
The will execute a statement and then evaluate a conditional expression.
do-while loop
The statements____ and ___ are used to
interrupt the normal flow of loops and the switch
statement.
break AND continue
The ____ is similar to the break statement, except it does not cause the loop to terminate. Rather it causes the loop to be continued.
continue statement
The ____ causes the flow of the program
to branch to the statement immediately following
the appropriate label.
goto statement
A _is a name that is formed with the same rules in identifiers and must be immediately followed by a colon.
label
The _ interrupts the normal sequential flow of a program, without involving a decision.
goto statement
Since goto statement is an example of _ it is difficult to use without the help of conditional branch statements.
unconditional branch
We can properly use goto statements by using some of the _to avoid infinite looping execution.
conditional branches