Professional Documents
Culture Documents
Program Using C++
Program Using C++
Programming Fundamental
By
Muhammad Hassan
2505-2023
Program BSCS
Teacher Name
Talha Ilyas
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