You are on page 1of 2

Cairo University Faculty of Engineering Credit Hour System GENN004

Lab 05 Loop Statements


All scripts should be stored in your FirstLastName folder and have clear names 1. Write a program to get a number N from the user, and check if it is negative: a message should be displayed to say that the number is negative. Otherwise: it should print the numbers from 0 to N (like 0 1 2 3 N). 2. Write a program to get an integer N from the user and prints the following statements based on the input. If N = 3. Then the output will be: Line 1 Line 2 Line 3 3. Given number of students in a class, read student grade one at a time and print the number of A students (grade >=90) 4. Given a number N, calculate the summation of the numbers from 1 to N and their average. 5. Given two numbers N1 and N2, calculate the summation from N1 to N2 and their average. 6. Write a program that gets two positive integer numbers X and Y and calculates X^Y. Hint: using loops with addition and multiplication. 7. Write a program that reads a number N from the user and prints the sum of the geometric series: Sum = 1^2 + 2^2 + 3^2 + 4^2 + . . . N^2 8. Write a program to read an array from the user and prints the sum of the odd elements and the sum of the even elements. 9. Write a program to find the least number of terms that must be added to the following series: Sum = 1^2 + 2^2 + 3^2 + 4^2 + . . . To give a sum = 10000 Lab 05 1/2

Cairo University Faculty of Engineering Credit Hour System GENN004 10. Write a program that will print the following multiplication table: 1 2 3 4 5 2 4 6 8 10 3 6 9 12 15 4 8 12 16 20 5 10 15 20 25

11. Write a program that will print the following multiplication table: 1 2 3 4 5 4 6 8 10

9 12 15

16 20

25

Lab 05

2/2

You might also like