Lab_7_Solution
Lab_7_Solution
Lab 7
Objective:
Application on loops
Application on nested loops
Working with arrays
Reading string from user
1. (Fibonacci series) Write a program that reads n, then generates the first n terms of the
Fibonacci series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55,
(Note: F1 = 0, F2 = 1, for every i > 2, Fi = Fi−2 + Fi−1).
Using arrays:
Alexandria University Computer and Communication
Faculty of Engineering CSE016 Computers &
Specialized Scientific Programs Programming
OR
Alexandria University Computer and Communication
Faculty of Engineering CSE016 Computers &
Specialized Scientific Programs Programming
4. (Bubble sort) Write a program that reads n integers (n <= 20) then use bubble sort to
sort the elements in ascending order.
Example:
5
Enter the elements: -1 7 5 30 -10
In ascending order: -10 -1 5 7 30