0% found this document useful (0 votes)
28 views9 pages

Screenshot 2023-09-20 at 3.12.53 PM

This document contains 40 programming problems covering various concepts in control structures and algorithms. The problems involve writing programs to: 1) Input and compare numbers to find minimum/maximum values, check properties of triangles and series, and calculate taxes, discounts and other values. 2) Check properties of numbers like prime, palindrome, perfect and generate patterns using loops. 3) Perform operations on numbers like removing digits, sorting digits, and finding factors, LCM, HCF and sums of series. 4) Accept user input for values to pass to functions that implement the required logic.

Uploaded by

jindalipad10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views9 pages

Screenshot 2023-09-20 at 3.12.53 PM

This document contains 40 programming problems covering various concepts in control structures and algorithms. The problems involve writing programs to: 1) Input and compare numbers to find minimum/maximum values, check properties of triangles and series, and calculate taxes, discounts and other values. 2) Check properties of numbers like prime, palindrome, perfect and generate patterns using loops. 3) Perform operations on numbers like removing digits, sorting digits, and finding factors, LCM, HCF and sums of series. 4) Accept user input for values to pass to functions that implement the required logic.

Uploaded by

jindalipad10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

XI CS CONTROL STATEMENTS

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

31. Write a program to input a number and check whether it is a


magic 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
magic number. For example 55=>
(5+5)=10=>(1+0)=1.
32. Write a program to input an integer and check whether it is
Harshad or Niven number or
not. A number is said to be Harshad if it is divisible by the sum
of the digits of that number,
example 126 and 1729.
33. Write a program to input a number and check whether it is a
Kaprekar number or not. Take
a positive whole number n that has d number of digits. Take the
square n and separate the
result into two pieces: a right-hand piece that has d digits and a
left-hand piece that has either
d or d-1 digits. Add these two pieces together. If the result is n,
then n is a Kaprekar number.
Examples are 9 (9 = 81, 8 + 1 = 9), 45 (45 = 2025, 20 + 25 =
2 2

45), and 297 (297 = 88209, 88 +


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:-

41. Write a program to input a number and print whether the


number is a special number or not.
(A number is said to be a special number, if the sum of the
factorial of the digits of the number
is same as the original number).
Example: 145 is a special number, because l! + 4! + 5! =
1+24+120 = 145
(Where ! stands for factorial of the number and the factorial
value of a number is the product of
all integers from 1 to that number, example 5! = 1*2*3*4*5 =
120).
42. Write a program to input a number and print all its prime
factors using prime factorization.
For Example,
INPUT: Enter an integer: 24
OUTPUT: Prime Factors using Prime Factorisation are:
2
2
2
3
43. Write a program to input a number and check whether it is a
Smith number or not. Smith
number is such a number, the sum of whose digits equals the
sum of the digits of its prime
factors.
Smith number is a composite number in which the sum of its
digits is equal to the sum of the
digits of all its prime factors.
For Example 378 is a Smith Number as the sum of the digits of
378 are : 3+7+8 = 18. The prime
factors of 378 are: 2, 3, 3, 3, 7 ( sum = 2+3+3+3+7 = 18).
Similarly 22 is a Smith Number as the sum of the digits are :
2+2=4. The prime factors of 22 are:
2 and 11 (Sum = 2+(1+1) = 4
Other Examples include 27, 58, 85, 94, 121, 166, 202, 265, etc.
45. A special two-digit number is such that when the sum of its
digits is added to the product of
its digits, the result is equal to the original two-digit number.
Example: Consider the number 59.
Sum of digits = 5 + 9 = 14
Product of its digits = 5 x 9 = 45
Sum of the sum of digits and product of digits = 14 + 45 = 59
Write a program to accept a two-digit number. Add the sum of
its digits to the product of its
digits.
If the value is equal to the number input, output the message
“Special 2-digitnumber” otherwise,
output the message “Not a special2-digit number”
46. Write a program to accept a number and check and display
whether it is a spy number or not.
(A number is spy if the sum its digits equals the product of its
digits.)
Example: consider the number 1124 , sum of the digits = 1 + 1 +
2+4=8
Product of the digits = 1 × 1 × 2 × 4 = 8

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy