PLT Exercises: Programming Logic and Techniques
PLT Exercises: Programming Logic and Techniques
1. Write a program to accept principle, rate of interest and time. Calculate simple interest and
display the same
2. Write a program to accept two numbers. Display the two numbers. Swap the two numbers
and display them again.
3. Write a program to accept a number and display whether it is an even or odd number
4. Write a program to accept a double value. Separate the whole value from the fractional
value and store them in two variables. Display the same.
5. Write a program to accept a student’s name and scores in three subject. Display the
1st, 2nd average and total. Display whether the student has secured 1st , 2nd , pass class or
has failed.
1st class is for a score of 60 and above,
2nd class is for a score of 50 and above, while pass class is for a score of 35 and above. If the
score is less than 35, then the student fails.
7. Write a program to accept name, empId, basic, special allowances, percentage of bonus and
monthly tax saving investments. The gross monthly salary is basic + special allowances.
Compute the annual salary. The gross annual salary also includes the bonus. Compute the
annual net salary, by deducting taxes as suggested.
a. Income upto 2.5 lakhs – exempted
b. Income from 2.5 lakhs to 5 lakhs – 5%
c. Income from 5 lakhs to 10 lakhs – 20%
d. Income from 10 lakhs onwards – 30%
However, if there is any tax saving investment, then there is further exemption of upto 1.5
lakhs annually. This would mean that by having tax saving investments of about 1.5 lakhs, an
income of 4 lakhs is non-taxable. Display the annual gross, annual net and tax payable.
9. Write a program to find the sum of all odd numbers from 1 to N. Accept N. Display the sum.
10. Write a program to find the reverse of a number. Store the reverse value in a different
variable. Display the reverse.
12. Write as many programs to generate the following series. In all the following cases, accept
N:
a. 4, 16, 36, 64, … N
b. 1, 2, 3, 4, 5, 6, … N
c. 1, 4, 27, 256, 3125, … N
d. 1, 4, 7, 12, 23, 42, 77, … N
e. 1, 4, 9, 25, 36, 49, 81, 100, … N
f. 1, 5, 13, 29, 49, 77, … N
13. Write a program to find the sum of all the prime numbers in the range n to m. Display each
prime number and the final sum.
14. Write a program to find the factorial of a given number. 0! is always 1. Factorial of a
negative number is not possible.
15. Write a program to find whether a given number is a finonacci number or not.
17. Write a program to accept a binary number and display it in the decimal form.
18. Write a program to display the 1st , 2nd , and 4th multiple of 7 which gives the remainder 1
when divided by 2,3,4,5 and 6
20. Write a program that takes amount and displays them in words
a. Input: 1234
b. Output: One thousand two hundred and thirty four only
21. Accept the item code, description, qty and price of an item. Compute the total for the item.
a. Accept the user’s choice. If the choice is ‘y’ then accept the next set of inputs for a
new item and compute the total. In this manner, compute the grand total for all the
items purchased by the customer.
b. If the grand total is more than Rs. 10,000/‐ then, the customer is allowed a discount
of 10%.
c. If the grand total is less than Rs. 1,000/‐ and the customer chooses to pay by card,
then a surcharge of 2.5% is levied on the grand total.
d. Display the grand total for the customer in number form and in words.
22. Write the pseudo codes to generate the following series. In all the following cases, accept N:
a. 1, 2, 6, 15, 31, 56 … N
b. 1, 1, 2, 3, 5, 8, 13, … N
c. 1, 2, 4, 6, 7,10, 10,14… N
d. 1, 5, 8, 14, 27, 49, … N
23. Write a program to find X ^ N (x to the power of n) without using in-built functions. Accept X
and n. Display the result.
25. Write a program to store N elements in an array of integer. Display the elements. Accept a
number to be searched. Display whether the number is found or not in the array (LINEAR
SEARCH).
27. Write a program to store elements into a M * N matrix of integer. Display the matrix and its
transpose.
28. Write a program to store elements into a N * N matrix of integer. Display whether it is an
identity matrix or not.
29. Write a program to store elements into a N * N matrix of integer. Display whether it is a
symmetric matrix or not.
31. Write the programs to generate the following outputs. In all the following cases, accept N:
*****
*****
*****
*****
:
N rows
11111
22222
33333
44444
:
N rows
12345
12345
12345
12345
:
N rows
*
**
***
****
:
N rows
1
12
123
1234
:
N rows
1
22
333
4444
:
N rows
1
23
456
7 8 9 10
:
N rows
1
12
358
:
:
N rows
33. Write the programs to generate the following outputs. In all the following cases, accept
N:
1
‐4 9
‐16 25 ‐36
:
:
N rows
35. Write a program to add two numbers containing any number of digits.
36. Write a program to populate a matrix of order 4x4 with 14 unique random numbers
37. Write a program to check whether a matrix of order 4x4 contains the numbers in the
normal sequence (1, 2, 3, 4,.....15)
38. Write a program to check whether a matrix of order 8x8 contains queens that does not
cross each other path (8 queen problem)