Please enable JavaScript.
Coggle requires JavaScript to display documents.
FUNDAMENTAL IN PROGRAMMING (ARITHMETIC STATEMENT (Addition (+) use to add…
FUNDAMENTAL IN PROGRAMMING
DATA TYPE
simply refers to the type and size of data associated with variables and functions.
INTEGER (int)
Whole numbers that can have both positive and negative values but no decimal values . (Example: 0, -5, 10) .The size of int is either 2 bytes(In older PC's) or 4 byte
DIFFERENCE BETWEEN LONG & SHORT (int)
-short int 2 bytes
long int 4 bytes
FLOAT(float/double)
Can hold real numbers such as: 2.34, -9.382, 5.0. The difference between
float
and
double
is that
float
can store
2 bytes
while
double
can store
4 bytes
CHARACTER (char)
use to declare character type variables
BOOLEAN
any data type that has either a true or false value, yes or no value, or on or off (1 or 0) value. By default, the boolean data type is set to false
VARIABLES
are used to store information to be referenced and manipulated in a computer program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves
DECLARATION
a declaration
determines the name and data type of a variable
or other element. Programmers declare variables by
writing the name of the variable into code, along with any data type
indicators and other required syntax.
ASSIGNMENT STATEMENT & EXPRESSION
Assignment
assigning a variable to it's fixed value by using the
assignment statement (=)
Example :int i = 0;
Expression
any legal combination of symbols that represents a value.Every expression consists of at least
one operand and can have one or more operators
Example : C = A + B; given here that
A,B & C are operands
while
the '+' and' =' are operators.
CONSTANT
is use to permanently sets the data of the assigned value by using the
CONST
keyword following the
data type
and
the variable name
and
equals it (=) to the value
that you want to set it to
example :
CONST
int PI = 3.142; or
final
int PI = 3.142 (in java);
NUMERIC TYPE CONVERSION
Happens when performing arithmetic on variables and constants of the same type, the result of
the operation retains that type
example : int x=3,y=4; result = x + y; (the output answer will be in integer)
ARITHMETIC STATEMENT
Addition (+)
use to add the values together
Subtraction (-)
is use to subtract the values
Division(/)
to divide the values
Multiplication (*)
to multiply
Remainder (%)
divide the values in order to get the remainder value
BOOLEAN DATA TYPE
generally may only consist of 2 output :
true
:check:
false
:green_cross:
LOGICAL OPERATOR
usually is use in a loop or an if else (boolean) statement
example : if (i<3)
{system.out.println("true");}
else
{system.out.println("false");}
<
(less than)
<=
(less than equals)
>=
(more than equals)
==
(equals to)
>
(more than)
!=
(not equals to)
BOOLEAN OPERATOR
Requires to do a truth table in order to use this operator
&&
(AND)
||
(OR)
!
(NOT)
^
(EXCLUSIVE OR)
FLOATING POINT DATA TYPE
are used to store values that contain decimal positions
FLOAT
The type float specifies a single-precision value that uses
32 bits of storage
DOUBLE
Double precision, as denoted by the double keyword, uses
64 bits
to store a value
OPERATOR PRECEDENCE AND ASSOCIATIVITY
more than one operators are involved in an expression, C language has a predefined rule of priority for the operators. This rule of priority of operators is called operator precedence
arithmetic operators
(
*
, %, /, +, -) is
higher
than
relational operators
(==, !=, >, <, >=, <=) and
precedence of relational
operator is
higher
than l
ogical operators
(&&, || and !)
EXAMPLE: (1>2 + 3 && 4) is equivalent to thi expression = ((1>(2+3)&&4)
CHAR DATA TYPE
May be assigned to char variables or made by using an escape sequence containing the Unicode value of the character
Char
is use for a
single character
and is assign with a
single quote(' ')
String
is use for
more than one character
and is assign with a
double quote (" ")
CONTROL STRUCTURE
Is the order in which statements are executed in a running program is called the flow of control
SELECTION
IF-ELSE
statement is use to determine between true or false satement
SWITCH
type of selection control mechanism used to allow the value of a variable or expression to change the control flow of program execution via search and map
LOOP
While Loop
, condition is tested at the beginning of the loop and if the condition is True then only statements in that loop will be executed. So, While loop executes the code block only if the condition is True.
Do While Loop
,condition is tested at the end of the loop so Do While executes the statements in the code block at least once even if the condition Fails.
for loop
provides a concise way of writing the loop structure. Unlike a while loop, a for statement consumes the initialization, condition and increment/decrement in one line thereby providing a shorter, easy to debug structure of looping