Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

LAB TASK #3

Programming Fundamental
By

Muhammad Hassan
2505-2023

Program BSCS

Teacher Name
Talha Ilyas

Faculty of Engineering Sciences and Technology


Hamdard University, Karachi, Pakistan
LAB TASK #3
1. Write an algorithm and draw flowchart for the following:
I. To print the multiplication table of any number entered by user.
II. To print the sum and average of any provided series of integer numbers.
III. To find the factorial of any number n. (n! =1x2x3x…n)
IV. To find all the divisors of a number n

Solution:
(i)Ans.

1. Input number N
2. Let i=1
3. If i<=10 then
Print N*i
i=i+1

Else go to step 5

4. Go To Step 3

5. Stop

(ii)Ans.

1. SUM = 1 to 10
2. Average = SUM/10
3. Print SUM and Average.
4. Stop
(iii)Ans.

1. Input number N
2. Let i=1
3. If i<=N Then
Fac=N*i
i=i+1

Else Go To step 6

4. Go To step 3
5. Print “Fac”
6. stop

(iv)Ans.

1. Input number N
2. i=1
3. If i>=N Then
Go To step 5

Else Go To step 4

4. if (i%N==0)

print”i”

i=i+1

Else Go To step 3

5. stop
2. Write an algorithm and draw flowchart to generate first n terms in Fibonacci series:
0,1,1,2,3,5…n (n>2).

Ans.
1. Input number of terms N
2. Let i=0 a=0 and b=1
3. For i=0 to N
c=a+b
Print c
a=b
b=c
4. Stop

You might also like