You are on page 1of 5

Introduction to programming

Lab 3
1. Do exercises on Code Learn: Loop statements and Loops: while and do-
while.
2. Calculate S(n) = 1 + 3 + 5 + … + (2k +1) with n > 0, 2k + 1 ≤ n.
3. Calculate n!
4. Calculate P(x, y) = xy with y ≥ 0. Note: do not use the Math.pow()
method.
5. Write a program that accepts a positive integer number from the user,
and check whether it is a prime number
6. Print a rectangle (m, n)
Example:
• Input: m = 5, n = 4
• Output:
* * * * *
* * * * *
* * * * *
* * * * *
7. Print an empty rectangle (m, n)
Example:
• Input: m = 5, n = 4
• Output:
* * * * *
* *
* *
* * * * *
8. Do exercises on SPOJ at the following link:
https://www.spoj.com/EIUPROGR/problems/introf20_02

You might also like