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

Department of Computer Engineering

University of Jaffna

EC2010: Computer Programming Time: 3 hours


Lab 02
Task 01
The Pythagoras theorem can be written as an equation relating the lengths of the
sides a, b and c.
𝑎2 + 𝑏2 = 𝑐 2
Write a C++ program to calculate the length of c with different a and b values.
Now check the all possible cases.

Task 02

In mathematics, the Fibonacci numbers are the numbers in the following integer
sequence, called the Fibonacci sequence:
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144,…………...
By definition, the first two numbers in the Fibonacci sequence are 1 and 1, and each
subsequent number is the sum of the previous two.
In mathematical terms, the sequence fn of Fibonacci numbers is defined by
the recurrence relation

Task 03

Write a C++ program to get the marks of 10 students in EC1010 subject from user
and store it in an array;
a. Find the sum of these marks and mean
b. Display the grades of each students as follows

Faculty of Engineering, UoJ Page 1


Marks Grade
Greater than or equal to 75 A
From 65 to 74 B
From 50 to 64 C
Less than 50 F
c. Who has the highest marks and lowest marks in EC1010?

Faculty of Engineering, UoJ Page 2

You might also like