0% found this document useful (0 votes)
14 views4 pages

Progld Midterm

Uploaded by

karenaurello123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

Progld Midterm

Uploaded by

karenaurello123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

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.

Common use cases for looping in flowchart:


•Iteration over a list or array: This involves processing each item in a collection one by one.
•Repeating a calculations or operation
•Validating user input
•Implementing algorithm

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.

Purpose: Provide a logical and systematic approach to solving problems.

Presentation: Can be expressed in natural language, pseudocode or programming code.

Focus: Emphasis the logic and sequence of steps.

•PSEUDOCODE - Is an artificial and informal language that helps programmers develop


algorithms. It is very similar to everyday english.
Example: Write an algorithm and draw a flowchart to convert the length in ft to cm.

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

Computer program list of instructions to be executed. a computer statement instructs the


compiler to print the text that ends with a semicolon.

Simple code
Line 1: #include <stdio.h>
Line 2:
Line 3: int main(){
Line 4: printf(“Hello World”);
Line 5: return 0;
Line 6:}

note: <stdio.h> - standard input/output .header file library


\n -new line

(//,/**/) 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.

The four operator classes:


arithmetic, relational, logical, Bitwise

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

Algebraic Expression - Expression in C


abc - a*b*c
a+bc - a+b*c
y³ - y*y*y
a / (b+c) - a/b+c
a(b+c) - a*(a+b)

Relational Operators
> - x>y
>= - x>=y
< - x<y
<= - x<=y
== - x==y
!= - x!=y

Logical Operators
&& -- And
ll -- or
! -- not

(++a)Pre-increment is the value of a after it is incremented.


(a++)Post-increment is the value of a before it is incremented
(--a)Pre-decrement is the value of a after it is decremented
(a–)Post-decrement is the value of a before it is decremented

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–;

For loop - Condition first before it do something


Do-while loop - Do or move first before conditions.

You might also like