Screenshot 2023-09-20 at 3.12.53 PM
Screenshot 2023-09-20 at 3.12.53 PM
WORKSHEET
1.Write a program to input 3 unique integers and print the
smallest among them.
2. Write a program to input the three angles of a triangle and
check whether it forms a triangle
or not, if it forms a triangle, check whether it is an equilateral,
isosceles or a scalene triangle.
(Hint: To form a triangle, the sum of the angles should be 180
degrees.
To form an equilateral triangle every angle should be equal.
To form an isosceles triangle any two angles should be equal.
To form a scalene triangle all three angles should be different
from each other.)
3. Write a program to input the three sides of a triangle and
check whether it forms a triangle or
not, if it forms a triangle, check whether it is an equilateral,
isosceles or a scalene triangle.
(Hint: To form a triangle, each side should be less the sum of the
other two sides.
To form an equilateral triangle every side should be equal.
To form an isosceles triangle any two sides should be equal.
To form a scalene triangle all three sides should be different
from each other.)
4. Write a program to accept three sides of a triangle as
parameter and check whether it can
form a triangle or not. If it forms a triangle, check whether it is
an acute angled, obtuse angled
or right-angled triangle.
(Hint: To form a triangle, each side should be less the sum of the
other two sides..
To form an acute angled triangle the square of every side should
be less than the sum of the
squares of the other two sides.
To form an obtuse angled triangle the square of any side should
be greater than the sum of the
squares of the other two sides.
To form an right angled triangle the square of any side should be
equal to the sum of the
squares of the other two sides.)
5. An electronics shop has announced the following seasonal
discounts on the purchase of
certain items.
Purchase Amount is` Discount on Laptop
Discount on desktop PC
0–2500 0.0%
5.0%
25001 – 57000 5.0%
7.5%
57001 – 100000 7.5%
10.0%
More than 100000 10.0%
15.0%
Write a program based on the above criteria, to input name,
address, amount of purchase and
the type of purchase (L for Laptop and D for Desktop) by a
customer. Compute and print the net
amount to be paid by a customer along with his name and
address.
(Hint: discount = (discount rate/100)* amount of purchase
Net amount = amount of purchase – discount)
6. Given below is a hypothetical table showing rates of Income
Tax for male citizens below the
age of 65 years:
Taxable Income (TI) in
Income Tax in
Does not exceed 1,60,000
Nil
Is greater than 1,60,000 and less than or
equal to 5,00,000
(TI – 1,60,000) * 10%
Is greater than 5,00,000 and less than or
equal to 8,00,000
[(TI – 5,00,000) * 20%] + 34,000
Is greater than 8,00,000
[(TI – 8,00,000) * 30%] + 94,000
Write a program to input the age, gender (male or female) and
Taxable Income of a person. If
the age is more than 65 years or the gender is female, display
“wrong category*.
If the age is less than or equal to 65 years and the gender is
male, compute and display the
Income Tax payable as per the table given above.
7. Write programs for each of the following to print the series:
a) 0, 3, 8, 15, 24, 35, …, 99
b) 1, 2, 4, 7, 11, 16, 22, 29, …, upto n terms. [Take n as input]
c) 2, 4, 8, 14, 22, 32, 44, 59, …, upto n terms. [Take n as input]
d) 1, 2, 5, 10, 17, 26, 37, 50, …, upto n terms. [Take n as input]
e) 1, 1, 2, 3, 5, 8, 13, 21, 34, …, upto n terms. [Take n as input]
f) 1, 2, 5, 12, 29, 70, 169, …, upto n terms. [Take n as input]
8. Write a program to display number is circular prime or not.
9. Write a program to find the sum of all 3 digit odd natural
numbers, which are multiples of 5.
10. Write a program to input an integer and find its factorial.
Factorial of a number is the product
of all natural numbers till that number. For example factorial of
5 is 120 since 1×2×3×4×5=120.
11. Write a program to input an integer and check whether it is a
prime number or not.
12. Write a program to input 10 integers and find the sum of
two-digit as well as three-digit
numbers separately.
13. Write a program to input 10 integers and display the largest
as well as the smallest integer.
14. Write a program to input 10 integers and check whether all
the entered numbers are even
numbers or not.
15. Write a program to input 10 integers and check whether the
entered numbers are in ascending
order or not.
For Example,
INPUT:
Enter 10 numbers: 10 12 13 25 45 55 67 78 106 122
OUTPUT:
The numbers are in ascending order.
INPUT:
Enter 10 numbers: 25 34 56 67 12 32 43 21 23 111
OUTPUT:
The numbers are not in ascending order.
16. Write a program to input 10 integers and check whether all
the entered numbers are same or
not.
For Example,
INPUT:
Enter 10 numbers: 10 12 13 234 45 34 67 78 76 12
OUTPUT:
All numbers are not same.
INPUT:
Enter 10 numbers: 12 12 12 12 12 12 12 12 12 12
OUTPUT:
All numbers are same.
17. Write a program to print the first 15 numbers of the Pell
series. Pell series is such a series
which starts from 1 and 2 , and subsequent numbers is the sum
of twice the previous number
and the number previous to the previous number. Pell series: 1,
2, 5, 12, 29, 70, 169, 408, 985,
2378, 5741, 13860, …
18. Write a program to find the sum of 1st 10 numbers of Lucas
series i.e. 2,1,3,4,7,11,18,…. Lucas
series is such a series which starting from 2 and 1, and
subsequent numbers are the sum of
the previous two numbers.
19. Write a program to input an integer and check whether it is
perfect, abundant or deficient
number. If the sum of the factors excluding itself is equal to that
number it is perfect, if greater
than that number it is abundant and if less than that number it is
deficient number.
20. Write a program to input two integers and check whether it
forms an amicable pair or not. An
amicable pair is such that, the sum of the factors excluding itself
of one number is the other
number and sum of the factors excluding itself of the other
number is this number.
Example, (220, 284). Since sum of factors excluding itself of :
220= 1+2+4+5+10+11+20+22+ 44+55+110=284
284= 1+ 2+4+71+142=220.
21. Using nested loops write programs to generate the following
patterns on the screen:
21. Write a program to input 10 numbers and print the largest
prime number if any.
22. Write a program to generate all 2 digit twisted prime
number. Twisted prime number is a
number which is prime and its reverse is also prime. Example 13
and 31.
23. Input an integer and form a new number where the digits are
in ascending order.
24. Write a program to pass an integer as argument and print the
largest as well as smallest digit.
25. Write a program to pass an integer as argument and print the
second largest digit.
26. Write a program to input an integer and remove all the even
digits from it.
For Example,
INPUT:
Enter an integer: 1234
OUTPUT:
13
27. Write a program to pass an integer as argument and print the
number by having the digits
arranged in ascending order.
28. Write a program to pass an integer as argument and check
whether all digits in it are unique
or not.
29. Write a program to pass an integer as argument and print the
frequency of each digit in it.
30. Write a program to input a number and check whether it is a
happy number or not. If you
iterate the process of summing the squares of the decimal digits
of a number and if this
process terminates in 1, then the original number is called a
happy number. For example 7=>
(7 )=49=> (4 +9 )=97=>(9 +7 )=130 =>(1 +3 +0 )=10 =>
2 2 2 2 2 2 2 2
(1 +0 )= 1.
2 2
209 = 297).
34. Write a program to input two integers and find their Least
Common Multiple(L.C.M).
For Example,
INPUT:
Enter 2 integers:
12
8
OUTPUT:
L.C.M. = 24
35. Write a program to input two integers and find their Highest
Common Factor(H.C.F).
For Example,
INPUT:
Enter 2 integers:
12
8
OUTPUT:
H.C.F. = 4
36. Write a menu driven class to accept a number from the user
and check whether it is a
Palindrome or a Perfect number.
(a) Palindrome number- (a number is a Palindrome which when
read in reverse order is same as
read in the right order) Example: 11, 101, 151, etc.
(b) Perfect number- (a number is called Perfect if it is equal to
the sum of its factors other than the
number itself.) Example: 6=1+2+3
37. Write a program to find the sum of the following series:
S=1+(1+2)+(1+2+3)+(1+2+3+4)+(1+2+3+4+5)+…+
(1+2+3+4+…+10)
38. Write a program to calculate and print the sum of each of the
following series:
(a) Sum (S) = 2 – 4 + 6 – 8 + ………. -20
(b) Sum (S) =x/2 + x/5 + x/8 + x/11 +…+ x/20
39. Write a program to find the sum of series, taking the value of
‘a’ and ‘n’ from the user.
S=(a+1)/2+(a+3)/4+(a+5)/6 ………..n terms
40. Write a program to compute and display the sum of the
following series:-