Questions
Questions
a loop. Make sure to use conditional statements to handle edge cases for n = 0 or n
= 1.
Prime Number Check: Create a function that checks if a number is prime. Use loops
to iterate through possible divisors and conditional statements to evaluate if the
number is divisible by any of them.
Sum of Even Numbers: Write a program that calculates the sum of all even numbers
from 1 to n. Use a loop to iterate through the numbers and a conditional statement
to check if a number is even.
Count Occurrences of a Character: Write a program that counts how many times a
specific character appears in a string. Use loops for traversal and conditional
statements to check for matches.
Grade Calculator: Create a function that takes a score and returns a grade (A, B,
C, D, F) based on predetermined ranges using conditional statements.
Find Unique Elements: Given an array, write a function to find and return the
unique elements. Use loops and conditional checks to filter out duplicates.
Number Pattern: Write a program that prints a number pattern, such as a right-angle
triangle made of asterisks (*) or numbers, using nested loops and conditional
statements to control the formatting.