Introducing 

Prezi AI.

Your new presentation assistant.

Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.

Loading…
Transcript

Practical

Sequential

Computer definition

Input -> Processing -> Output

Example of writing a program :-

Write a program that takes two inputs from the user and prints their sum

Z = A + B

Steps

Analysis

Analysis

Input:

A , B

Process:

A + B

Output:

z

Operators

Arithmetic

Logic

Assignment

  • This operator assigns a value or an expression to a variable.

  • The symbol used for this operator is an arrow pointing left: 

Cost  10

Price  Cost * 2

Tax  Price * 0.14

Service  Price * 0.12

PaidAmount  Tax + Service

Design

Design

  • We Design the algorithm

Algorithm is a steps needed to preform a task

There are two ways to design an algorithm:

Flowcharts

Flowchart

Flow chart of Z = A + B

Z = A + B

Psuedocode

Describes what an algorithm does using plain English Statements, Mathematical notations and keywords that are commonly found in high level language

Pseudocode

INPUT in psuedocode

In pseudocode we indicate the operation of taking input from users by either of the following keywords:

- INPUT

- READ

Input

OUTPUT in psuedocode

In pseudocode we indicate the operation of displaying a value or an output or any message by using either of the following keywords:

- OUTPUT

- PRINT

Output

Assignment operator

Assignment operator is used to assign the value or expression to a variable.

Assignment operator

Variable

  • It is a named memory space which is used to store values.

  • Variable usually stores two kind of information:

1- All the input values from user must be stored in a variable

2- Result of some mathematical operation must be stored in a variable.

  • These are the rules while assigning name to a variable:

- There is no space in a variable name

- Variable name should not be a keyword of pseudocode

- Variable name should be relevant.

Solution in Psuedocode

INPUT A,B

Z <- A + B

OUTPUT Z

Data types

In order for a computer to process and store data effectively, we need to specify the data type of each variable

Declare A,B,Z : Integer

INPUT A,B

Z <- A + B

OUTPUT Z

Data types

Examples

Design a program that reads from the user three numbers and outputs the result according to the following equation:

Z = A*B+C

Design a program that inputs three numbers from the user and outputs the sum & average.

Design a program that input radius from the user and prints the circumference

Implementation

After designing the algorithm, the algorithm is transformed into code using a programming language

(for example: c++, java, python).

Testing

The last phase of the programming, this phase is done after implementation by testing how the program works, we will discuss this later.

Selection

Selection

IF CONDITIONS :

In computer science, conditional statements are features which perform different computations or actions depending on whether a programmer-specified boolean condition evaluates to true or false

Design a program that inputs a number and prints whether it’s positive or negative.

if True

Checking if the input more than 0

if False

DECLARE A : INTEGER

Input A

IF ( A > 0) THEN

OUTPUT "positive"

ELSE

OUTPUT "negative"

IF CONDITION

How does it work?

Examples

Design a program that inputs two numbers from the user and outputs the bigger one.

DECLARE Num1, Num2 : INTEGER

INPUT Num1

INPUT Num2

IF Num1 > Num2 THEN

OUTPUT "The bigger number is: ", Num1

ELSE

OUTPUT "The bigger number is: ", Num2

ENDIF

Design a program that inputs a number and prints whether it’s positive or negative

DECLARE Num: INTEGER

INPUT Num

IF Num > 0 THEN

OUTPUT "Positive"

ELSE

IF Num < 0 THEN

OUTPUT "Negative"

ENDIF

ENDIF

Design a program that inputs 2 exam scores. If the average score is greater than or equal to 50 then the program should print out “Passed” otherwise print “Failed”

DECLARE Exam1, Exam2 : INTEGER

DECLARE Avg : REAL

INPUT Exam1

INPUT Exam2

Avg <- (Exam1 + Exam2) / 2

IF Avg >= 50 THEN

OUTPUT "Passed"

ELSE

OUTPUT "Failed"

ENDIF

Design a program that inputs an age of a student. Produce an error message if the age is negative, otherwise print the age inputted.

DECLARE Age : INTEGER

INPUT Age

IF Age < 0 THEN

OUTPUT "This is an invalid age"

ELSE

OUTPUT "The student's age is: ", Age

ENDIF

Design a program that inputs two numbers from the user and outputs their division. DON’T FORGET TO VALIDATE.

DECLARE Num1, Num2 : INTEGER

DECLARE Result : REAL

INPUT Num1

INPUT Num2

IF Num2 = 0 THEN

OUTPUT "Invalid operation"

ELSE

Result <- Num1 / Num2

OUTPUT "The result is: ", Result

ENDIF

Design a program that inputs a number and prints whether it’s positive or negative or zero

DECLARE Num : INTEGER

INPUT Num

IF Num > 0 THEN

OUTPUT "Positive"

ELSE

IF Num < 0 THEN

OUTPUT "Negative"

ELSE

OUTPUT "Zero"

ENDIF

ENDIF

Design a program that takes two numbers from the user and displays the bigger the number or if they are equal print “equal”

DECLARE Num1, Num2 : INTEGER

INPUT Num1

INPUT Num2

IF Num1 > Num2 THEN

OUTPUT "The bigger number is: ", Num1

ELSE

IF Num2 > Num1 THEN

OUTPUT "The bigger number is: ", Num2

ELSE

OUTPUT "Both answers are equal"

ENDIF

ENDIF

Design a program that reads from the user the course number and outputs the course name according to the following : 

DECLARE CourseNum: INTEGER

OUTPUT “Enter the course number”

INPUT CourseNum

IF CourseNum = 1 THEN

OUTPUT “Computer Science”

ELSE

IF CourseNum = 2 THEN

OUTPUT “ICT”

ELSE

IF CourseNum =3 THEN

OUTPUT “ Math”

ELSE

IF CourseNum =4 THEN

OUTPUT ”Bio”

ELSE

OUTPUT ”Invalid course number”

ENDIF

ENDIF

ENDIF

ENDIF

More Examples

Design a program that inputs a number and prints “Correct range” if the number is between 1 and 10 inclusive, otherwise the program outputs “Wrong range”

Design a program that inputs a number and prints “Correct range” if the number is between 50 and 90 (inclusive) or between -100 and -10 (exclusive), otherwise the program outputs “Wrong range”

Design a program that reads from the user three numbers and outputs the maximum.

Assume that the three numbers are different

Design a program that reads from the user his/her mark and outputs the grade according to the following grade boundaries:

Design a program, using pseudocode and flowchart, that takes the salary of 3 months (salaries cannot be negative) as inputs and output the financial status according to the following table:

A supermarket puts a discount according to the amount paid by its customers. Design a program that inputs the total of a receipt (before the discount) and then output the updated total that the customer should pay after applying the discount. The discounts are shown in this table:

Design a program that reads from the user the course number and outputs the course name according to the following : 

Design a program that inputs a student’s class year and outputs the corresponding class name according to the following : 

Design a program that inputs from the user the month number and outputs the number of days of this month

Given that :

-Jan, March, May, July, August, October, December have 31 days

-April, June, September, November have 30 days

-February has 28 days

Media

Here, we will learn how to include media on a web page.

<media>

1

The image tag <img> is self-closing and allows you to add an image to a web page.

2

3

1

2

The image tag has a required attribute called src, which must be set to the image’s source, or location of the image.

<img src="dog.jpg" alt="My Dog">

3

image description

image filename

The alt attribute allows you to provide a description of the image.

Images

A self-closing tag does not require a closing tag—content is contained within the opening tag rather than the opening and closing tags.

<Images>

Videos

<Videos>

3

The width and height attributes set the size of the video displayed in the browser.

<video src ="myVideo.mpr" width = "320"

1

height="340r" controls >

The video tag displays video and requires a src attribute with a link to the video source.

4

Video not supported

The controls attribute instructs the browser to include basic video controls such as pause, play, and skip.

2

</video>

Unlike the image tag, the video tag requires an opening and closing tag.

5

The text “Video not supported” will only be displayed if the browser is unable to load the video.

Your turn

From what you’ve learned here, you can make a basic webpage using HTML.

Create a web page with the heading “My Media,” and add some text using the paragraph tags to give an overview of the media you will use.

<your_turn>

Be sure to include at least one image and one video, and don’t forget to use the correct attributes.

i

Designed by Next Interactive Presentations:

www.nextinterativa.com/

Learn more about creating dynamic, engaging presentations with Prezi