0% found this document useful (0 votes)
31 views5 pages

Conditional Statement

The document contains a list of 50 programming tasks that require writing `if-else` statements to evaluate various conditions. Each task specifies a condition to check, such as age, number properties, string characteristics, and more, with instructions on what to print based on the evaluation. The tasks are designed to practice conditional logic in programming.

Uploaded by

anandkc11111
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views5 pages

Conditional Statement

The document contains a list of 50 programming tasks that require writing `if-else` statements to evaluate various conditions. Each task specifies a condition to check, such as age, number properties, string characteristics, and more, with instructions on what to print based on the evaluation. The tasks are designed to practice conditional logic in programming.

Uploaded by

anandkc11111
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1. Age Check: Write an `if-else` statement to check if a person is 18 years old or older.

Print "Adult" if
true, otherwise "Not an adult."

2. Number Sign: Write an `if-else` statement to check if a number is positive. Print "Positive" if true,
otherwise "Not positive."

3. Even or Odd: Write an `if-else` statement to check if a number is even. Print "Even" if true, otherwise
"Odd."

4. Vowel or Consonant: Write an `if-else` statement to check if a given character is a vowel. Print "Vowel"
if true, otherwise "Consonant."

5. Check Zero: Write an `if-else` statement to check if a number is zero. Print "Zero" if true, otherwise
"Non-zero."

6. Multiple of Five: Write an `if-else` statement to check if a number is a multiple of 5. Print "Multiple of
5" if true, otherwise "Not a multiple of 5."

7. Greater Than Ten: Write an `if-else` statement to check if a number is greater than 10. Print "Greater
than 10" if true, otherwise "10 or less."

8. Check Equality: Write an `if-else` statement to check if two numbers are equal. Print "Equal" if true,
otherwise "Not equal."

9. String Length Check: Write an `if-else` statement to check if the length of a string is greater than 5.
Print "Long string" if true, otherwise "Short string."

10. Check Uppercase: Write an `if-else` statement to check if a character is uppercase. Print "Uppercase"
if true, otherwise "Lowercase."

11. Check Weekend: Write an `if-else` statement to check if a day of the week is Saturday. Print
"Weekend" if true, otherwise "Not weekend."

12. Age Category: Write an `if-else` statement to check if a person is a child (under 12). Print "Child" if
true, otherwise "Not a child."
13. Temperature Check: Write an `if-else` statement to check if the temperature is above 30 degrees. Print
"Hot" if true, otherwise "Cold."

14. Number Range: Write an `if-else` statement to check if a number is between 1 and 100. Print "In
range" if true, otherwise "Out of range."

15. Grade Check: Write an `if-else` statement to check if a student’s score is greater than or equal to 50.
Print "Pass" if true, otherwise "Fail."

16. Divisibility Check: Write an `if-else` statement to check if a number is divisible by 3. Print "Divisible
by 3" if true, otherwise "Not divisible by 3."

17. Morning or Afternoon: Write an `if-else` statement to check if the time is before 12 PM. Print
"Morning" if true, otherwise "Afternoon."

18. Teenager Check: Write an `if-else` statement to check if a person’s age is between 13 and 19. Print
"Teenager" if true, otherwise "Not a teenager."

19. String Content Check: Write an `if-else` statement to check if a string contains the letter "a". Print
"Contains 'a'" if true, otherwise "Does not contain 'a'."

20. Leap Year Check: Write an `if-else` statement to check if a given year is a leap year. Print "Leap year"
if true, otherwise "Not a leap year."

21. Check Negative: Write an `if-else` statement to check if a number is negative. Print "Negative" if true,
otherwise "Positive or zero."

22. Password Match: Write an `if-else` statement to check if a user’s input matches the password "1234".
Print "Access granted" if true, otherwise "Access denied."

23. Greater Number: Write an `if-else` statement to check if the first of two numbers is greater. Print
"First is greater" if true, otherwise "Second is greater or equal."

24. Prime Check: Write an `if-else` statement to check if a number is greater than 1 and divisible only by
1 and itself. Print "Prime" if true, otherwise "Not prime."
25. Eligible for Discount: Write an `if-else` statement to check if a customer’s age is 65 or older. Print
"Eligible for senior discount" if true, otherwise "Not eligible."

26. String Comparison: Write an `if-else` statement to check if two strings are exactly the same. Print
"Match" if true, otherwise "Do not match."

27. Multiples of Two: Write an `if-else` statement to check if a number is a multiple of 2. Print "Multiple
of 2" if true, otherwise "Not a multiple of 2."

28. Driving License Check: Write an `if-else` statement to check if a person is old enough to get a driving
license (age 18 or older). Print "Eligible" if true, otherwise "Not eligible."

29. Letter Case Check: Write an `if-else` statement to check if a character is lowercase. Print "Lowercase"
if true, otherwise "Uppercase."

30. Number Check: Write an `if-else` statement to check if a number is a single-digit number. Print
"Single-digit" if true, otherwise "More than one digit."

31. Divisibility by 10: Write an `if-else` statement to check if a number is divisible by 10. Print "Divisible
by 10" if true, otherwise "Not divisible by 10."

32. Check Month: Write an `if-else` statement to check if a month number corresponds to a month with
31 days. Print "31 days" if true, otherwise "Not 31 days."

33. Password Length Check: Write an `if-else` statement to check if a password is at least 8 characters
long. Print "Valid password" if true, otherwise "Password too short."

34. Check for Zero: Write an `if-else` statement to check if a number is zero. Print "Zero" if true,
otherwise "Not zero."

35. Grade A Check: Write an `if-else` statement to check if a student’s score is 90 or above. Print "Grade
A" if true, otherwise "Less than Grade A."

36. Empty String Check: Write an `if-else` statement to check if a string is empty. Print "Empty" if true,
otherwise "Not empty."
37. Multiple of 4: Write an `if-else` statement to check if a number is a multiple of 4. Print "Multiple of 4"
if true, otherwise "Not a multiple of 4."

38. Day of the Week: Write an `if-else` statement to check if a given day is Sunday. Print "Sunday" if true,
otherwise "Not Sunday."

39. String Starts with A: Write an `if-else` statement to check if a string starts with the letter "A". Print
"Starts with A" if true, otherwise "Does not start with A."

40. Check for Space: Write an `if-else` statement to check if a string contains a space. Print "Contains
space" if true, otherwise "No space."

41. String Length Even: Write an `if-else` statement to check if the length of a string is an even number.
Print "Even length" if true, otherwise "Odd length."

42. Temperature Conversion: Write an `if-else` statement to check if a temperature in Celsius is above 100
degrees. Print "Above boiling point" if true, otherwise "Below boiling point."

43. Work Hours Check: Write an `if-else` statement to check if the current time is during work hours (9
AM to 5 PM). Print "Working hours" if true, otherwise "Off hours."

44. BMI Check: Write an `if-else` statement to check if a person’s Body Mass Index (BMI) is in the
healthy range (18.5 to 24.9). Print "Healthy" if true, otherwise "Not healthy."

45. Check Odd Number: Write an `if-else` statement to check if a number is odd. Print "Odd" if true,
otherwise "Even."

46. Check for Digit: Write an `if-else` statement to check if a character is a digit (0-9). Print "Digit" if
true, otherwise "Not a digit."

47. Check for Exclamation: Write an `if-else` statement to check if a string ends with an exclamation
mark (!). Print "Exclamation mark" if true, otherwise "No exclamation mark."

48. Day Check: Write an `if-else` statement to check if today is a weekday (Monday to Friday). Print
"Weekday" if true, otherwise "Weekend."
49. Check Square Number: Write an `if-else` statement to check if a number is a perfect square. Print
"Perfect square" if true, otherwise "Not a perfect square."

50. Temperature Range Check: Write an `if-else` statement to check if a temperature is between 15 and 25
degrees Celsius. Print "Comfortable" if true, otherwise "Uncomfortable."

You might also like