0% found this document useful (0 votes)
97 views7 pages

WIX1002 Tutorial: Basic Programming Logic

The document contains 7 sections that describe simple programs to perform basic calculations and conditional logic. Each section outlines the input, process, and output of a program. The programs include multiplying two numbers, checking if a random number is greater than 50, checking a test mark, comparing scores in a game, calculating the perimeter of a rectangle, finding the smallest of 10 generated numbers, and counting odd and even numbers among 10 random numbers.

Uploaded by

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

WIX1002 Tutorial: Basic Programming Logic

The document contains 7 sections that describe simple programs to perform basic calculations and conditional logic. Each section outlines the input, process, and output of a program. The programs include multiplying two numbers, checking if a random number is greater than 50, checking a test mark, comparing scores in a game, calculating the perimeter of a rectangle, finding the smallest of 10 generated numbers, and counting odd and even numbers among 10 random numbers.

Uploaded by

Tan Connei
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

WIX1002 - Tutorial 1

Part 1
1)

Input Process Output


Enter number 1 Multiplication of numbers= Multiplication of the two
Enter number 2 Num1*Num2 numbers
Display multiplication of
the two numbers

1) Enter num1
2) Enter num2
3) Multiplication of the two numbers = Num1*Num2
4) Display multiplication of the two numbers

Start

Enter num 1
Enter numnum
Enter 1 2

Multiplication of the two numbers =

num1*num2

Display Multiplication
of the two numbers

End
2)

Input Process Output


Random number by user If num>50 Yes / No
Display “Yes”
else “No”

1) Enter a random number


2) If num>50, display “Yes”
3) Else display “No”

Start

Enter a random
number

Num>50

no

yes

Display “Yes”
Display “No”

End
3)

Input Process Output


Enter a mark If mark>=40 Pass or Fail
Display “Pass”
Else ,
Display “Fail”

1) Enter a mark
2) If mark>=40 then display “Pass”
3) Else, display “Fail”

Start

Enter a mark

Mark>=40 NO

yes

Display “Pass” Display”Fail”

End
4)

Input Process Output


Enter Player 1’s score If Player 1’s score > Player 2’s score , Player 1 wins
then display “Player 1 wins”
Enter Player 2’s score If Player 2’s score > Player 1’s score, Player 2 wins
Then display “Player 2 wins” Draw
If Player 1’s score = Player 2’s score ,
Then display “Draw”

Start

Enter Player 1’s score


Enter Player 2’s score

Player 1’s score =


Player 2’s score

Player 2’s score >


Player 1’s score >
Player 2’s score Player 1 ’s score

Player 1 wins Draw Player 2 wins

End
5)

Input Process Output


Enter length Perimeter of rectangle= Perimeter of rectangle
Enter width (2*length)+(2*width)
Display Perimeter of rectangle

1) Enter length
2) Enter width
3) Calculate perimeter as : perimeter of rectangle = (2*length)+(2*width)
4) Display perimeter of rectangle

Start

Enter length

Enter width

Perimeter of rectangle=

(2*length)+(2*width)

Display perimeter
of rectangle

End
6)

Input Process Output

Generate 10 numbers Determine smallest number Smallest number


Display smallest number

1) Generate 10 numbers
2) Smallest=num[0]
Where I is 1 -9 ,
Num[i]<smallest
Smallest=num[i]
3) Display num[i]

Start

Generate 10
numbers

Smallest=num[0]

Num[i]<smallest

Smallest=num[i]

Display smallest num

End
7)

Input Process Output


10 random numbers ranged Determine number of odd Number of odd numbers
from 10-100 and even numbers and number of even
Display number of odd and numbers
even numbers

1) Generate 10 random numbers ranged from 10-100


2) If num%2==1 , number of odd numbers +1
3) Else, if num%2==0 , number of even numbers +1
4) Display number of even and odd numbers

Start

Generate 10
numbers from
10-100

If num%2==1,

Number of odd numbers +1

Else if num%2==0,

Number of even numbers +1

Display number of odd


and even number

End

You might also like