0% found this document useful (0 votes)
41 views12 pages

Hedi 10

The document contains 14 code snippets that demonstrate various programming concepts like finding the maximum of two numbers, calculating the average of three numbers, checking if a number is even or odd, calculating the sum of a list of numbers, calculating the factorial of a number, checking if a number is prime, converting between Celsius and Fahrenheit, swapping two numbers, calculating the area of a rectangle, finding the square root of a number, checking if a year is a leap year, calculating the percentage of passed students, calculating the power of a number, and checking if a character is a vowel. Each code snippet follows a basic structure of declaring variables, getting input, performing calculations, and displaying output.

Uploaded by

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

Hedi 10

The document contains 14 code snippets that demonstrate various programming concepts like finding the maximum of two numbers, calculating the average of three numbers, checking if a number is even or odd, calculating the sum of a list of numbers, calculating the factorial of a number, checking if a number is prime, converting between Celsius and Fahrenheit, swapping two numbers, calculating the area of a rectangle, finding the square root of a number, checking if a year is a leap year, calculating the percentage of passed students, calculating the power of a number, and checking if a character is a vowel. Each code snippet follows a basic structure of declaring variables, getting input, performing calculations, and displaying output.

Uploaded by

hedizarayane9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Prepared: hedi madih mohammed

Supervisor: Dr.Solaf Ali


1) Find the maximum of two numbers:

Start

Declare variables
N1,N2

Read value N1,N2

False True
If A>B

Print B Print A

Stop
2) Calculate the average of three numbers:

Start

Declare variable
A ,B,C and sum

Read value A,B,C

Sum=(A+B+C)/3

Display

Stop
2) Check if a number is Even odd:

Start

Declare variable
number

Read Value
number

False If True
N%2=0

Display Odd Display Even


Number Number

End
3) Sum of number list:

Step1: Star
Step2: declare variable list sum,i
Step3: initialize variables i=1
Step4: read value list
i= list*length
4.1 sum list[i]+sum
4.2 i= 1+i
Step5: Display sum
Step6: Stop

4)factorial calculation :

Start

Read value of number

Fact=1,i=1

False
I<=num

true

Fact=fact*i

i=1+i

Stop
6) check for prime numbers:

Start

Read value n

i=2

F
i<n

I%n==0 T

i=1+i
T F
i==n

Print”No is prime” Print”Yes is prime”

Stop
7) convert Celsius to fehrenheit and vica versa:

Start

Read the temperature to be


convert from the user:cel

Initialize f=0

F=(9\5*C)+32

Display the value of F

Stop
8) swap two numbers:

Step1: Start
Step2: Read the value of a, b
Step3: a = a + b
b=a-b
a=a-b
Step4: Print the value of a and b
Step5: Stop

9) Calculate the area of a rectanlgular:

Start

Read length and breadth

Area = length*breadth

Display Area

Stop
:find the square root of a number )10

start

“Enter the value of a


number:” GET a_number

false If true
A_number>=0

Square_root sqrt(a_number) Square_root sqrt(-a_number)

PUT ”imaginary root”


PUT ”Real root”

PUT ”value of square root :


“ + square root

stop
11) check leap year:

stop

Year %4==0
true false
Year%100==0

Year%400==0

Leap year
Not leap year

Stop
: calculate percentage of passed students )12

step 1: start
step 2: read marks m1, m2, m3
step 3: calculate sum = m1+m2+m3
step 4: calculate per=(sum/3)*100
step 5: display sum, per
step 6: stop

13) Calculate the Power of a Number:

Input A number x and the power n

Output: x*n

1. Procedure power (x, n):

2.p← 1

3. Repeat for i=1 to n

4. p← p.x

5.Return p

6. End Procedure
14) Find if a given character is vowel:

Start

Declare variables character

Read value character

false true

Not vowel Vowel

Stop

You might also like