Assignment ICT by M.Saoodulhassan

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

1.

Pseudo-code for Area of Rectangle:


1. Make three variables (l, w, a)
2. Input : w (width)
3. Input : l (length)
4. Compute a = l*w
5. Output : a (area of rectangle)
2. Pseudo-code for Circumference of circle:
1. Make two variables (r, c)
2. Input : r (radius)
3. Compute c = 2*3.14*r
4. Output : c (circumference of circle)
3. Pseudo-code for Maximum of three numbers:
1. Make three variables (x, y, z)
2. Input : x (num1)
3. Input : y (num2)
4. Input : z (num3)
5. If x > y And x > z then

Output : x is the largest

6. Else If y > x And y > z then

Output : y is the largest

7. Else

Output : z is the largest

4. Pseudo-code for Minimum of three numbers:


1. Make three variables (x, y, z)
2. Input : x (num1)
3. Input : y (num2)
4. Input : z (num3)
5. If x < y And x < z then

Output : x is the smallest

6. Else If y < x And y < z then

Output : y is the smallest

7. Else

Output : z is the smallest

5. Pseudo-code for to check if a number is even or odd:


1. Make a variable (x)
2. Input : x (num1)
3. If x divided by 2 has no remainder then
Output : Even

4. Else

Output : (Odd

6. Pseudo-code to check if a year is a leap year:


1. Make three variables (x, l, n)
2. Input : x (Year)
3. If x is evenly divided by 4 And

x is not divided by 100 Or

x is divided by 400 Then

Output : l (leap year)

4. Else
Output : n (not a leap year)
7. Pseudo-code to covert temperature from Celsius to Fahrenheit:
1. Make two variables (c, f)
2. Input : c (temperature In Celsius)
3. Compute f = (c*9/5) + 32
4. Output : f (temperature in Fahrenheit)
8. Pseudo-code to check if a number is prime:
1. Make three variables (x, y, z)
2. Input : x (num1)
3. Set y to True (assuming x prime until proven otherwise)
4. If x <= 1 , Set y to False
5. For each value of z from (2 to x-1):
If x is divisible by z , Set y to False
6. Exit the loop
7. If y is true then
Output : x is a prime number
8. If y is false then
Output : x is not a prime number
9. Pseudo-code to calculate reverse of a number:
1. Make two variables (x, y)
2. Input : x (num1 to reverse)
3. Initialize y (reversednum) to 0
4. While x is greater than 0 :
- Get last digit of x (remainder when divided by 10)
- Append last digit to y
- Remove last digit from x

5. End While

6. Output : y (reversed number)


10. Pseudo-code to find Fibonacci sequence up to given number of terms:

1. Make five variables (x, f, s, n, count)

2. Input : x (number of terms in Fibonacci sequence)

3. Set f (first Fibonacci number) to 0

4. Set s (second Fibonacci number) to 1

5. Initialize counter variable “count" to 0

6. While count < x:

- Find the n (next Fibonacci number) as n=f + s

- Output : f (current Fibonacci number)

- Update f to be value of s (f=s)

- Update s to be value of n (s=n)

- Increment the “ count” by 1

7. End While

You might also like