Level 2
1. Number Sign Checker
Description:
Accept an integer and check whether it is Positive, Negative, or Zero using if-else
ladder.
Example:
Input: -5
Output: Negative
Constraints:
Integer input range.
Test Cases:
1. Input: 10
Output: Positive
2. Input: -20
Output: Negative
3. Input: 0
Output: Zero
4. Input: 999
Output: Positive
5. Input: -1
Output: Negative
2. Even or Odd Checker
Description:
Accept an integer and check whether it is Even or Odd using the modulus
operator (%).
Example:
Input: 4
Output: Even
Constraints:
Input can be positive or negative.
Test Cases:
1. Input: 10
Output: Even
2. Input: 7
Output: Odd
3. Input: 0
Output: Even (0 is mathematically even)
4. Input: -5
Output: Odd
5. Input: -22
Output: Even
3. Vowel or Consonant
Description:
Accept a single character. Check if it is a Vowel (a, e, i, o, u) or a Consonant.
Handle both uppercase and lowercase inputs. If input is not an alphabet, print
"Invalid Input".
Example:
Input: E
Output: Vowel
Constraints:
Single Character input.
Test Cases:
1. Input: a
Output: Vowel
2. Input: Z
Output: Consonant
3. Input: i
Output: Vowel
4. Input: B
Output: Consonant
5. Input: 1
Output: Invalid Input
4. Character Type Identifier
Description:
Accept a character and check whether it is a Digit, Alphabet, or Special
Character.
Example:
Input: @
Output: Special Character
Constraints:
ASCII range checks.
Test Cases:
1. Input: A
Output: Alphabet
2. Input: 9
Output: Digit
3. Input: $
Output: Special Character
4. Input: z
Output: Alphabet
5. Input: 0
Output: Digit
5. Leap Year Checker
Description:
Accept a year and check if it is a leap year. (Divisible by 4, unless it is a century
year, then it must be divisible by 400).
Example:
Input: 2024
Output: Leap Year
Constraints:
Year > 0
Test Cases:
1. Input: 2024
Output: Leap Year
2. Input: 2023
Output: Not a Leap Year
3. Input: 2000
Output: Leap Year (Century Leap)
4. Input: 1900
Output: Not a Leap Year (Century Non-Leap)
5. Input: 2100
Output: Not a Leap Year
6. Largest of Two Numbers
Description:
Accept two integers and print the largest one using if-else.
Example:
Input: 10 20
Output: 20
Constraints:
Integers.
Test Cases:
1. Input: 5 10
Output: 10
2. Input: 100 2
Output: 100
3. Input: -5 -10
Output: -5
4. Input: 8 8
Output: 8 (Equal case)
5. Input: 0 5
Output: 5
7. First N Natural Numbers
Description:
Accept a number N (e.g., 10) and print the first N natural numbers using a loop.
(Modified from "First 10" to "First N" to allow testing).
Example:
Input: 5
Output: 1 2 3 4 5
Constraints:
N>0
Test Cases:
1. Input: 5
Output: 1 2 3 4 5
2. Input: 3
Output: 1 2 3
3. Input: 1
Output: 1
4. Input: 0
Output: (No Output)
5. Input: 10
Output: 1 2 3 4 5 6 7 8 9 10
8. Multiplication Table
Description:
Accept an integer N and print its multiplication table from 1 to 10.
Example:
Input: 5
Output: 5 10 15 20 25 30 35 40 45 50
Constraints:
Integer input.
Test Cases:
1. Input: 2
Output: 2 4 6 8 10 12 14 16 18 20
2. Input: 5
Output: 5 10 15 20 25 30 35 40 45 50
3. Input: 10
Output: 10 20 30 40 50 60 70 80 90 100
4. Input: 0
Output: 0 0 0 0 0 0 0 0 0 0
5. Input: -1
Output: -1 -2 -3 -4 -5 -6 -7 -8 -9 -10
9. Sum of Natural Numbers
Description:
Accept a number N and print the sum of all natural numbers from 1 to N.
Example:
Input: 5
Output: 15 (1+2+3+4+5)
Constraints:
N >= 0
Test Cases:
1. Input: 5
Output: 15
2. Input: 10
Output: 55
3. Input: 1
Output: 1
4. Input: 100
Output: 5050
5. Input: 0
Output: 0
10. Factorial Calculator
Description:
Accept an integer and print its factorial using a loop.
Example:
Input: 5
Output: 120
Constraints:
0 <= N <= 20
Test Cases:
1. Input: 5
Output: 120
2. Input: 4
Output: 24
3. Input: 0
Output: 1
4. Input: 1
Output: 1
5. Input: 6
Output: 720
11. Prime Number Check
Description:
Accept an integer and check whether it is a prime number.
Example:
Input: 7
Output: Prime
Constraints:
N>1
Test Cases:
1. Input: 7
Output: Prime
2. Input: 10
Output: Not Prime
3. Input: 2
Output: Prime
4. Input: 13
Output: Prime
5. Input: 1
Output: Not Prime
12. Largest of Three (Nested If-Else)
Description:
Accept 3 integers and find the largest using nested if-else logic.
Example:
Input: 10 20 5
Output: 20
Constraints:
Integers.
Test Cases:
1. Input: 10 20 30
Output: 30
2. Input: 50 10 5
Output: 50
3. Input: 10 50 20
Output: 50
4. Input: 5 5 2
Output: 5
5. Input: 9 9 9
Output: 9
13. Sum of Digits
Description:
Accept a number and print the sum of its digits.
Example:
Input: 123
Output: 6
Constraints:
N >= 0
Test Cases:
1. Input: 123
Output: 6
2. Input: 55
Output: 10
3. Input: 100
Output: 1
4. Input: 9
Output: 9
5. Input: 987
Output: 24
14. Reverse a Number
Description:
Accept a number and print its reverse.
Example:
Input: 123
Output: 321
Constraints:
N >= 0
Test Cases:
1. Input: 123
Output: 321
2. Input: 100
Output: 1 (Trailing zeros logic: 001 becomes 1)
3. Input: 5
Output: 5
4. Input: 102
Output: 201
5. Input: 9876
Output: 6789
15. Palindrome Checker
Description:
Accept an integer and check whether it is a palindrome (Equal to its reverse).
Example:
Input: 121
Output: Palindrome
Constraints:
Positive Integers.
Test Cases:
1. Input: 121
Output: Palindrome
2. Input: 123
Output: Not Palindrome
3. Input: 1001
Output: Palindrome
4. Input: 1
Output: Palindrome
5. Input: 12321
Output: Palindrome
16. Armstrong Number
Description:
Accept an integer and check if it is an Armstrong number (Sum of cubes of digits
equals the number).
Example:
Input: 153
Output: Armstrong
Constraints:
Input > 0
Test Cases:
1. Input: 153
Output: Armstrong
2. Input: 370
Output: Armstrong
3. Input: 123
Output: Not Armstrong
4. Input: 1
Output: Armstrong
5. Input: 9474
Output: Not Armstrong (Usually checked for 3 digits, if strict 3-digit: Not
Armstrong. If generalized N-digit logic: Armstrong). Portal usually expects
3-digit logic at Level 2.
17. Fibonacci Series
Description:
Accept a number N and print the Fibonacci series up to N terms.
Example:
Input: 5
Output: 0 1 1 2 3
Constraints:
N >= 1
Test Cases:
1. Input: 5
Output: 0 1 1 2 3
2. Input: 2
Output: 0 1
3. Input: 1
Output: 0
4. Input: 7
Output: 0 1 1 2 3 5 8
5. Input: 3
Output: 0 1 1
18. Simple Calculator (Switch)
Description:
Format: Operator (+, -, *, /, %) followed by two numbers. Use switch case.
Example:
Input: + 5 10
Output: 15
Constraints:
Division by zero handling.
Test Cases:
1. Input: + 10 20
Output: 30
2. Input: - 20 10
Output: 10
3. Input: * 5 4
Output: 20
4. Input: / 10 2
Output: 5
5. Input: % 10 3
Output: 1
19. Star Pyramid Pattern
Description:
Accept N and print a right-angled triangle star pattern.
Example:
Input: 3
Output:
*
**
***
Constraints:
N>0
Test Cases:
1. Input: 2
Output:
*
**
2. Input: 1
Output:
*
3. Input: 3
Output:
*
**
***
4. Input: 4
Output:
*
**
***
****
5. Input: 0
Output: (No Output)
20. Primes between 1 and N
Description:
Accept an integer N and print all prime numbers between 1 and N.
Example:
Input: 10
Output: 2 3 5 7
Constraints:
N>1
Test Cases:
1. Input: 10
Output: 2 3 5 7
2. Input: 5
Output: 2 3 5
3. Input: 20
Output: 2 3 5 7 11 13 17 19
4. Input: 2
Output: 2
5. Input: 1
Output: (No Output)