Progld Midterm
Progld Midterm
PROGLD
•LOOPING
Looping in flowchart is used to represent
repetitive actions or process. This means that a certain set of steps will be repeated multiple
times until a specific condition is met.
Example: Create a flowchart that will print the numbers from 1-10
•ALGORITHM
Definition: A step by step procedure for solving a problem or accomplishing a task. It's a
sequence of instructions that is well-defined and guaranteed to terminate.
Pseudocode:
•input the length in ft (LFT)
•calculate the length in cm (LCM) by multiplying (LFT) with 30
•print length in cm (LCM)
Algorithm:
step 1: input LFT
step 2: LCM = LFT x 30
step 3: print LCM
Flowchart:
C language
- By Dennis Ritchie at bell laboratories on 1972
- c++, c#
- General purpose
- popular
Simple code
Line 1: #include <stdio.h>
Line 2:
Line 3: int main(){
Line 4: printf(“Hello World”);
Line 5: return 0;
Line 6:}
(//,/**/) Comments are used to explain the code to make it more readable.
C variables:
Int - stores integers or whole numbers
Ex: 1,2,3
Float - stores floating numbers or with decimals.
Ex: 19.99
Char - store single character
Ex: 'a' , 'B’
Operators are symbols that tell the compiler to perform specific mathematical or logic
manipulation.
Arithmetic operators:
(+) unary or binary plus
(-)unary or binary minus
(*) multiplication
(/)division
(%) modulus operator
Precedence of operators:
() Parentheses Highest
*, /, % Whichever
come first from to
left to right
+, - Whichever Lowest
come first from
left to right
EX. 1) (5+4)*3
2) 5+4 *3
Relational Operators
> - x>y
>= - x>=y
< - x<y
<= - x<=y
== - x==y
!= - x!=y
Logical Operators
&& -- And
ll -- or
! -- not
Ex. 1. a = 5 ; c = 0; Answers: 1. c = 6 , a = 6
c = ++a;
2. a = 5 ; c = 0; 2. c = 5 , a = 6
c = a++;
3. b = 3 ; c = 0; 3. c = 2 , b = 2
c = --b;
4. b = 3 ; c = 0; 4. c = 3 , b = 2
c = b–;