0% found this document useful (0 votes)
4 views11 pages

PSP2 - Intro To Output, Input and Processing

The document provides an introduction to basic programming concepts, focusing on creating a simple calculator program to add two numbers. It outlines the steps for coding, including input, processing, and output, along with a class activity to find the average of three numbers. Students are expected to learn how to perform basic calculations and execute their code using a compiler.

Uploaded by

aaliyah.nixon
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)
4 views11 pages

PSP2 - Intro To Output, Input and Processing

The document provides an introduction to basic programming concepts, focusing on creating a simple calculator program to add two numbers. It outlines the steps for coding, including input, processing, and output, along with a class activity to find the average of three numbers. Students are expected to learn how to perform basic calculations and execute their code using a compiler.

Uploaded by

aaliyah.nixon
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/ 11

Topic: Introduction to Problem Solving and Program

Sub-topic: Introduction to output, input and processing

Objective: Students should be able to perform basic calculations in programming.


Table of Content

The problem ............................................................................................................ 3


Solution .................................................................................................................. 4
Open your compiler ................................................................................................. 5
Create your code ..................................................................................................... 6
Explanation ........................................................................................................... 10
Class Activity ......................................................................................................... 11
The problem

When we create code, it's normally to solve a problem

Here is the problem we are going to solve today.

“We need a calculator program to check the sum of two numbers”


Solution

1. We need the user to enter 1 number and let the computer store that number
2. Ask for another number, then store that number
3. Then add the two number and store the result in sum
4. Print sum on screen
Open your compiler

Reopen your compiler and delete everything.


Create your code

Step 1:Type your program name

Step 2: Declare your variables

Step 3: Start your program by typing begin

Step 4: Ask the user for the first number

Step 5: Store the number in num1

Step 6: repeat for num2


Step 7: Add the two numbers and store the result in sum

Step 8 : Print the value in sum

Step 9 : End the program


Step 10: Execute the code

Step 11: Type your first value then, press enter. I typed 18

Step 12: Type your next value in then press enter


Step 13: Look at the result
Explanation

Program Name: program SimpleAddition; - This names our program "SimpleAddition".

Variables Section: var num1, num2, sum: integer; - This creates three integer variables
to store our numbers and result.

Begin and End: These mark where our instructions start and finish, just like in the Hello
World program.

Input/Output:

• The writeln lines display messages to the user

• The readln lines wait for the user to type a number and press Enter

• Each instruction ends with a semicolon (;)

Calculation: sum := num1 + num2; - This adds the two numbers together and stores the
result in the variable called "sum".

Final Output: writeln('The sum is: ', sum); - This displays the result to the user.

Period: The program ends with a period (.) to mark its completion.
Class Activity
Create and run the program below that finds the average of three numbers

Steps.

Saving and uploading.

1. When you are finished, take a screenshot like the one above and save it as
“Averageofthree program”. Upload it to the Teams assignment.

You might also like