04 Loop
04 Loop
Difficulty
SL Problem statement
levels
1. Write a program (WAP) that will print following series upto Nth terms. *
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, …….
2. Write a program (WAP) that will print following series upto Nth terms. *
1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31 …….
3. Write a program (WAP) that will print following series upto Nth terms. **
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, …….
4. Write a program (WAP) that will take N numbers as inputs and compute their *
average.
(Restriction: Without using any array)
5. Write a program (WAP) that will take two numbers X and Y as inputs. Then it *
will print the square of X and increment (if X<Y) or decrement (if X>Y) X by 1,
until X reaches Y. If and when X is equal to Y, the program prints “Reached!”
7. Write a program (WAP) that will run and show keyboard inputs until the user *
types an ’A’ at the keyboard.
Sample input Sample output
X Input 1: X
1 Input 2: 1
a Input 3: a
A
8. Write a program (WAP) that will reverse the digits of an input integer. **
9. Write a program (WAP) that will find the grade of N students. For each *
student, it will take the marks of his/her attendance (on 5 marks), assignment
(on 10 marks), class test (on 15 marks), midterm (on 50 marks), term final (on
100 marks). Then based on the tables shown below, the program will output
his grade.
Attendance (A) 5%
Assignments (HW) 10%
Class Tests (CT) 15%
Midterm (MT) 30%
Final (TF) 40%
10. Write a program (WAP) that will give the sum of first Nth terms for the **
following series.
1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, …….
Sample input Sample output
2 Result: -1
3 Result: 2
4 Result: -2
11. Write a program (WAP) that will calculate the result for the first Nth terms of **
the following series. [In that series sum, dot sign (.) means multiplication]
12.2 + 22.3 + 32.4 + 42.5 + …….
12. Write a program (WAP) that will print Fibonacci series upto Nth terms. **
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …….
13. Write a program (WAP) that will print the factorial (N!) of a given number N. **
Please see the sample input output.
14. Write a program (WAP) that will find nCr where n >= r; n and r are integers. **
16. WAP that will find the GCD (greatest common divisor) and LCM (least common **
multiple) of two positive integers.
18. WAP that will determine whether an integer is palindrome number or not. **
19. WAP that will calculate following mathematical function for the input of x. Use ***
only the series to solve the problem.
20. Write a program that takes an integer number n as input and find out the sum **
of the following series up to n terms.
1 + 12 + 123 + 1234 + …….