0% found this document useful (0 votes)
17 views18 pages

Computer 2024

The document discusses algorithms and control structures like addition, subtraction, multiplication, division and if-else, case, for, while, repeat-until loops. Pseudocodes, flowcharts and source codes are provided for each algorithm and control structure as examples.

Uploaded by

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

Computer 2024

The document discusses algorithms and control structures like addition, subtraction, multiplication, division and if-else, case, for, while, repeat-until loops. Pseudocodes, flowcharts and source codes are provided for each algorithm and control structure as examples.

Uploaded by

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

Name: Wania Anis

Class: IX
Section: Aristotle
Subject: Computer
Topic: Algorithms
Submission Date: 17th April 2024
Pseudocode:

ADDITION

DECLARE Number1← Integer

DECLARE Numbe2← Integer

DECLARE Sum← Integer

INITIALIZE Number1←0, Number2←0, Sum←0

OUTPUT “Enter Number1”

INPUT Number1

OUTPUT “Enter Number2”

INPUT Number2

OUTPUT “Sum”

INPUT Number1+Number2

SOURCE CODE:
FLOWCHART:

Start

Number1←0

Number←0

Sum←0

Input Number1,
Number2

Sum←
Number1+
Number2

Output Sum

Stop
Pseudocode:

DECLARE Number1, Number2, Difference← integer

INITIALIZE Number1←0, Number←0, Difference←0

OUTPUT “Enter Number1”

INPUT Number1

OUTPUT “Enter Number2”

INPUT Number2

OUTPUT “Difference”

INPUT Number1- Number2

Source Code:
Flowchart:

Start

Number1←0,
Number2←0,
Difference←0

Input Number1,
Number2

Difference←
Number1-Number2

Stop
Pseudocode:

Flowchart:

Start

Stop

Number1←0, Number←0,
Product←0

Input
Number1,
Number2

Product← Number*
Number2
Pseudocode:

DECLARE Number1←Integer

DECLARE Number2←Integer

DECLARE Result← Integer

INITIALIZE Number1←0, number2←0, Result←0

OUTPUT “Enter Number1”

INPUT Number1

OUTPUT “Enter Number2”

INPUT Number2

OUTPUT “Result”

INPUT Number1/ Number2

Source code:
Flowchart:

Start

Number1←0,
Number2←0,
Result←0

Input Number1,
number2

Result←number1/ Number2

Stop
Control Statements

If…then…else

Pseudocode:

DECLARE Age← integer

INITIALIZE Age←0

IF Age >18

THEN

OUTPUT “Adult”

ELSE

OUTPUT “Child”

ENDIF

Source code:

Flowchart:

Start

Age←0
If Age>18
No Yes

Print “Child” Print “Adult”

Stop

Case of…otherwise…end case:

Pseudocode:

DECLARE Number1← Integer, Number2←Integer

INITIALIZE Number1←0, Number2←0, Operator←0

INPUT Number1

INPUT Number2

INPUT Operator

CASE OF OPERATOR:

“+”: Result←Number1+Number2

“-”: Result←Number1-Number2

“*”: Result←Number1*Number2

“/”: Result←Number1/Number2

OTHERWISE

PRINT “Error”

END CASE

PRINT “Result”
Flowchart:

Start

Number1←0,
Number2←0

Input Number1,
Number2,
Operator

Stop
Case of operator:
+← number1+ number2
-← number1-number2
*← number1* number2
/← number1/ number2

OTHERWISE:

Output “Error”

Iterative statements

FOR…TO..NEXT loop:

Pseudocode:

FOR counter← 1 To 10

OUTPUT “Enter name of student”

INPUT Student Name (counter)


NEXT

Source code:

Flowchart:

Start

Count←0

FOR Counter← 1
TO 10

INPUT Student
name (Counter)
OUTPUT “
Enter Student
name”

Count←
Count + 1

Stop

Repeat…until loop

Pseudocode:

DECLARE Total← Integer, Mark← Integer

INITIALIZE Total←0

INITIALIZE Mark←0

REPEAT

Total← Total+ mark

OUTPUT “Enter value for mark, -1 to finish”

INPUT Mark

UNTIL Mark = -1

Flowchart:
Start

Total←0, Mark←0

Total← Total+
marks

Input mark

Total← total+ Mark

<>-1 to finish

Stop
While…do loop:

Pseudo code:

Total←0

Output “Enter value for mark, -1 to finish”

INPUT Mark

WHILE Mark <> -1 DO

Total← Total + Mark

OUTPUT “Enter value for ark, -1 to finish”

INPUT Mark

END WHILE
Source Code:

Flowchart:

Start

Total←0, Mark←0

Input mark
While
marks<>-1 to
finish

Total← total+ Mark

Input mark

Stop

Total← 0

OUTPUT "Enter value for mark, -1 to finish"

INPUT Mark

WHILE Mark <> -1 DO


Total← Total+ Mark

OUTPUT “Enter value for Mark,-1 to finish”

INPUT Mark

ENDWHILE.

Source code:

You might also like