Introduction to Computer Science lab - CSE 112
Final Exam - 75 minutes
Marks - 24
Problem 1: (PT - 5) Categorize a Number as Positive, Negative, or Zero and Determine Its
Parity
Input: A single integer.
Output:
If the number is positive, print "The number is positive and even" or "The number is positive
and odd" based on its parity.
If the number is negative, print "The number is negative and even" or "The number is
negative and odd" based on its parity.
If the number is zero, print "The number is zero and even".
Example:
Input: -5
Output: The number is negative and odd
Input: 4
Output: The number is positive and even
Problem 2: (Pt - 6.5) Vowel or Consonant
Input: A single lowercase letter.
Output:
"Vowel" if the input is 'a', 'e', 'i', 'o', or 'u'.
"Consonant" for any other letter.
Example:
Input: a
Output: Vowel
Problem 3: (Pt - 6) Determine if a Number is a Palindrome
Input: A single integer.
Output:
"The number is a palindrome" if the reverse of the number is the same as the original
number.
"The number is not a palindrome" otherwise.
Example:
Input: 121
Output: The number is a palindrome
Problem 4: (Pt - 6) Find the Largest of Two Numbers Using a Function
Input: Two integers.
Output:
The larger of the two numbers, determined using a function.
If both numbers are equal, print "Both numbers are equal".
Instructions:
Create a function called find_largest that takes two integers as parameters and returns the
larger of the two.
Use the function in the main program to determine and print the result.
Example:
Input:
7 15
Output:
The largest number is 15
Problem 5 : (PT - 6.5) Calculate the Factorial of a Number
Input: A single non-negative integer, n.
Output:
The factorial of the number (n!), calculated as n × (n-1) × (n-2) × ... × 1.
Example:
Input: 5
Output: The factorial is 120