This document discusses how to write algorithms and programs to solve problems. It provides an example of writing an algorithm to find the sum of two numbers in words and pseudocode. It then shows how to write a program in Turbo Pascal to calculate the sum. The program prompts the user to input two numbers, adds them together, and displays the sum. The document aims to demonstrate how algorithms and programming can be used to solve problems in a straightforward manner.
2. First you have to find a solution to a
problem
Example: Find the sum of two numbers
Formulate a solution in your own words
3. Your answer may look like this:
Take two numbers
Add them
Display the answer
(this is your solution in words)
4. Algorithm
in words in pseudocode
Take two numbers
Add them
Display the answer
Enter num1
Enter num2
Sum num1 + num2
Write sum
5. Programming (Turbo Pascal)
Enter num1
Enter num2
Sum num1 + num2
Write sum
Writeln(Please enter a
number.);
Readln(num1);
Writeln(Please enter another
number.);
Readln(num2);
Sum := num1 + num2 ;
Writeln(The sum of ,num1, and
, num2, is ,sum, .)
6. In Turbo Pascal, your program should look like this:
Program sum1;
uses crt;
var
num1, num2, sum: integer;
begin
clrscr;
writeln(Please enter a number.);
readln(num1);
writeln(Please enter another number.);
readln(num2);
sum:= num1 + num2;
writeln(The sum of ,num1, and , num2, is ,sum, .) ;
readln
end.