Hands-On - Control Flow Statements - Questions
Hands-On - Control Flow Statements - Questions
Hands-on No. :3
Date : 17.09.2024
Question
Question Detail Level
No.
1 Take values of length and breadth of a rectangle from user and Easy
check if it is square or not.
Sample Input: 5, 3
Sample Output: Not a Square
Sample Input: 7, 7
Sample Output: Square
2 Write a program to check whether the given number is odd or Easy
even.
Sample Input: 20
Sample Output: Even
Sample Input: 87
Sample Output: Odd
3 Write a program to get a number from the user and print whether Easy
it is positive, negative or zero.
Sample Input: 56
Sample Output: positive
Sample Input: -235
Sample Output: negative
4 Write a program to check whether a kid is eligible for kinder Easy
garden school admission. If a child is of age 4 or more then
he/she is eligible.
Sample Input: 4
Sample Output: Eligible
Sample Input: 2
Sample Output: Not Eligible
Sample Input: 3, 4
Sample Output: 7
Sample Input: 13, 8
Sample Output: 19
8 In Chai Sung’s family the birthright will be given to the firstborn Easy
as a custom. Who will get the birthright among his three sons
Choi Sung, Moui Sung, and Bhoi Sung if their ages are the input
values?
9 Write a program to check error in marks entry while user enters Easy
the marks in the system. Consider Error as marks entered less
than 0 and more than 100.
Sample Input: 83
Sample Input: -6
10 Write a program that accepts three numbers from the user and Easy
prints "increasing" if the numbers are in increasing order,
"decreasing" if the numbers are in decreasing order, and
"Neither increasing or decreasing order" otherwise.
Sample Input: 3 6 8
Sample Output: Increasing order
Sample Input: 9 5 1
Sample Output: Decreasing order
Sample Input: 4 9 2
Sample Output: Neither increasing nor decreasing order
11 Smith and John, grade 3 students playing number games. When Easy
Smith gives a number John will say the natural numbers up to
that number but in reverse order. Shia, their friend will say the
sum of those numbers. Help John and Smith with your program.
Sample Input: 4
Sample Output: 4 3 2 1 , 10
Sample Input: 7
Sample Output: 7 6 5 4 3 2 1 , 28
12 Kittu the ‘Giant Ant’ has 100 rooms in its colony. All the ants in Easy
the colony can crawl from 1 room to another, from there to
another and so on. But our ‘Kittu’ has a special power that
makes him to jump from one room to next 10th room directly.
Sample Input: 2
Sample output: 2 12 22 32 … 92
Sample Input: 5
Sample Output: 5 15 25 35 … 95
Sample Input: 6
Sample Output: 1 2 3 4 5 7 8 9 10 11 12 13 14 15 16 17 18 19
20
Sample Input: 17
Sample Output: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19
20
Sample Input: 23
Sample Output: Invalid Input
14 Write a program to print only the numbers divisible by 3 and 5 Easy
for a given number from 1.
Sample Input: 20
Sample Output: 3 5 6 9 10 12 15 18 20
Sample Input: 40
Sample Output: 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35
36 39 40
15 Jack and Emma are playing a number game. Jack should say the Easy
sum of the numbers that Emma says. He should sum until Emma
says ‘zero’. Help Emma to check if Jack is right or not by telling
her the answer.
Sample Input: 2 5 9 4 0
Sample Output: 20
Sample Input: 6 8 2 5 3 9 0
Sample Output: 33
Sample Input: 13
Sample Output: 1 3 5 7 9 11 13
Sample Input: 16
Sample Output: 2 4 6 8 10 12 14 16
17 Given a number, Find the factorial of the given number using Easy
iteratives.
Sample Input: 5
Sample Output: 120
Sample Input: 7
Sample Output: 5040
18 There is a movie club for under 20 in the city, where the entry is Medium
age restricted. Based on their age allow them into either
‘Cartoon Club’ or ‘Teens Club’.
Sample Input: 10
Sample Output: Cartoon Club
Sample Input: 15
Sample Output: Teens Club
Sample Input: -10
Sample Output: Invalid Age
Sample Input: 25
Sample Output: Not Allowed
19 Write a program if an integer variable currentNumber is odd, Medium
change its value so that it is now 3 times currentNumber plus 1,
otherwise change its value so that it is now half of
currentNumber.
Sample Input: 17
Sample Output: 52
Sample Input: 26
Sample Input: 2 2
Sample Output: 1
24 Write a program to read a number N. Find the sum of odd and Medium
even numbers from 1 to N numbers (inclusive).
Sample Input: 10
Sample Output: 25 30
Sample Input: 15
Sample Output: 64 56
25 Reina and Sierra were playing a game. Reina would give out Medium
number, and Sierra must reverse the given number. Help Sierra
by writing program to reverse the number. Note that Reina
should give a five-digit number.
Sample Input: 91
Sample Output: No
Sample Input: 97
Sample Output: Yes
27 Write a program to print all prime numbers between 1 and Medium
N(inclusive). N will be the input.
Sample Input: 5
Sample Output: 2 3 5
28 A student will not be allowed to sit in exam if his/her attendance Hard
is less than 75%. Number of classes held, and the Number of
classes attended are the inputs. Display the attendance
percentage and the eligibility of the student for the exam. Allow
Sample Input: 11
Sample Output: Autumn
Sample Input: 13
Sample Output: Invalid month