Author: devangini123

🌙 Problem Statement: Write a program that accepts a number (age) and checks whether the person is eligible to vote. A person is eligible if their age is 18 or more. Example: Input: 20 Process: Check if 20 ≥ 18 → Eligible Output: You are eligible to vote. Approach: Take input from the user (or define a variable). Use a conditional statement to check if age is 18 or above. If yes, print “You are eligible to vote.” Otherwise, print “You are not eligible to vote.” Visualisation: Explanation: ● Accept age as input. ● Use if age >= 18 to…

Read More

🌙 Problem Statement: Write a function that takes an integer and returns its square. Call this function and prints the result. Square(x) is a function that computes the square of a number. It returns the result instead of printing it. Example: Input: 3 Process: square(3) = 3 × 3 = 9 Output: The square is: 9 Approach: Define a function that takes one integer as input. Compute the square of the number (multiply it by itself). Return the result from the function. Call the function and print the returned value. Visualisation: Explanation: ● Square(x) is a function that takes an…

Read More

🌙 Problem Statement: Write a Program that defines a function to calculate the sum of two integers and prints the result. Call this function by passing two integer values. Approach: Define a function that takes two numbers as input. Add the two numbers inside the function. Call the function with two integers & print the result. Example: Input: 5, 3 Process: a + b => 5 + 3 = 8 Output: 8 Visualisation: Explanation: ● Sum(a, b) is a function that takes two arguments. ● Adds them and stores the result in a variable named add. ● Prints the result.…

Read More