Class VIII OCT-2019 Programs-60 Copies
Class VIII OCT-2019 Programs-60 Copies
Page 1 of 8 www.esaby.org
provide a message that the number is "too small". Otherwise, print a
message WELL DONE, WE THINK ALIKE.
20. Write a program to input 3 unique integers and print the smallest among
them.
21. Write a program to input 3 unique integers and print the smallest among
them without using the logical operator && (AND).
22. Write a program to accept three integer numbers and check whether all of
them are even numbers or not; if they are, it should print "All are even",
otherwise check whether all three are odd or not, if they are it should print
"All are odd". If none of the above conditions are true, it should print "They
are mixed".
23. Write a program to accept 3 integer numbers and check whether the last
digit of every number is 7 or not. If it is, it should print "The last digit of all
the numbers is 7", otherwise it should print, "The last digit is not 7 for every
number".
24. Write a program to input a year and check whether it is a leap year or not.
25. Write a program to accept three angles 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, the sum of the angles should be 180 degrees.
To form an acute angled triangle every angle should be less than 90 degrees.
To form an obtuse angled triangle either of the angle should be more than 90
degrees. To form a right angled triangle either of the angle should be equal to
90 degrees.)
26. 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.)
27. 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.)
28. 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 a right-angled triangle, the square of any side should be equal to the
sum of the
Page 2 of 8 www.esaby.org
29. Write a program to accept a mark obtained by a student in computer science
and print the grades accordingly:
30. A bike shop hires bikes by the day at different rates throughout the year.
The following table shows how the hire charge varies throughout the year:
The proprietor also gives a discount on the number of days a bike is hired
for. If the hire period is greater than 7 days, then a reduction of 25% is
made. For every bike hired a deposit of rupees 50.00 must be paid. Write a
program to input the season and number of days the bike is required for and
output the hire charge including the deposit.
31. A cloth showroom has announced the following festival discounts on the
purchase of items, based on the total cost of the items purchased:
Write a program to input the total cost and compute and display the amount
to be paid by the customer after availing the discount.
In addition to the above, every consumer has to pay Rs.200 as service charge
per month. Write a program to input the amount of units consumed and
calculate the total charges payable (bill) by the consumer.
Page 3 of 8 www.esaby.org
33. A library charges a fine for books returned late. Following are the fines:
First five days : 40 paise per day. Six to ten days : 65 paise per day.
Above ten days : 80 paise per day. Design a program to calculate the fine
assuming that a book is returned n days late.
34. Write a program to find the result of the following functions: F(x)=4×x+y if
x>0 F(x)= 4×x–y if x<0 Both x and y should be of float data type and should
be taken as input.
35. Write a program to input an integer and check whether it is a 5-digit number
or not. If it is, extract the central digit and print it. Example:
INPUT: Enter an integer: 76549
OUTPUT: Central digit: 5
INPUT: Enter an integer: 12976
OUTPUT: Central digit: 9
INPUT: Enter an integer: 126
OUTPUT: Not a 5-digit number
36. Write a program to input an integer and check whether it is a 4-digit number
or not. If it is, find the sum of the first and last digit.
Example
INPUT: Enter an integer: 4765
OUTPUT: Sum of the first and last digit: 9
INPUT: Enter an integer: 7839
OUTPUT: Sum of the first and last digit: 16
INPUT: Enter an integer: 126
OUTPUT: Not a 4-digit number
37. Write a program to input an integer and check whether it is a 3-digit number
or not. If it is check whether the sum of the first and last digit is an even or
an odd number.
Example
INPUT: Enter an integer: 476
OUTPUT: Sum of the first and last digit is an even number
INPUT: Enter an integer: 784OUTPUT: Sum of the first and last digit is an
odd number
INPUT: Enter an integer: 12
OUTPUT: Not a 3-digit number
38. Write a program to input an integer and check whether it is a 4-digit number
or not. If it is, divide it into two equal halves and find their sum.
Example
INPUT: Enter an integer: 4762
OUTPUT: Sum of the 2 halves: 109
[Hint: 47+62=109]
INPUT: Enter an integer: 9863
OUTPUT: Sum of the 2 halves: 161
[Hint: 98+63=161]
INPUT: Enter an integer: 12
OUTPUT: Not a 4-digit number
39. Write a program to find the gross salary of an employee for the following
allowances and deductions. Use meaningful variables with the class name
Employee and Basic Pay as an input.
Page 4 of 8 www.esaby.org
40. To foster a sense of water conservation, the water department has an annual
water conservation tax policy. The taxes are based on the water
consumption of the consumer. The tax rates are as follows:
Write a program to input the water consumed annually in gallons and
output the tax payable.
Page 5 of 8 www.esaby.org
Page 6 of 8 www.esaby.org
Page 7 of 8 www.esaby.org
Page 8 of 8 www.esaby.org