Practice 100 Go Lang Conditional Statements Coding Questions, TechnoVlogs

Practice 100 Go Lang Conditional Statements Coding Questions


Q1. Write a Go program to check if a number is positive or negative.  
  Input:    
  -5
  Expected Output:  
  The number is negative

Q2. Write a Go program to check if a number is even or odd.  
  Input:    
  7
  Expected Output:  
  The number is odd

Q3. Write a Go program to find the maximum of two numbers.  
  Input:    
  10, 20
  Expected Output:  
  Maximum: 20

Q4. Write a Go program to find the minimum of three numbers.  
  Input:    
  5, 8, 3
  Expected Output:  
  Minimum: 3

Q5. Write a Go program to check if a number is divisible by 3 and 5.  
  Input:    
  15
  Expected Output:  
  15 is divisible by both 3 and 5

Q6. Write a Go program to check if a character is a vowel or a consonant.  
  Input:    
  a
  Expected Output:  
  a is a vowel

Q7. Write a Go program to check if a year is a leap year.  
  Input:    
  2024
  Expected Output:  
  2024 is a leap year

Q8. Write a Go program to check if a string is empty or not.  
  Input:    
  ""
  Expected Output:  
  The string is empty

Q9. Write a Go program to check if a number is a multiple of 10.  
  Input:    
  30
  Expected Output:  
  30 is a multiple of 10

Q10. Write a Go program to check if a character is uppercase or lowercase.  
   Input:     
   G
   Expected Output:  
   G is an uppercase letter

Q11. Write a Go program to find the largest of three numbers using nested if.  
   Input:     
   12, 7, 20
   Expected Output:  
   Largest number: 20

Q12. Write a Go program to check if a number is in a specific range (10-50).  
   Input:     
   25
   Expected Output:  
   25 is in the range of 10-50

Q13. Write a Go program to check if a number is zero, positive, or negative.  
   Input:     
   0
   Expected Output:  
   The number is zero

Q14. Write a Go program to determine the grade of a student based on marks.  
   Input:     
   Marks: 85
   Expected Output:  
   Grade: A

Q15. Write a Go program to check if two numbers are equal.  
   Input:     
   10, 20
   Expected Output:  
   10 and 20 are not equal

Q16. Write a Go program to check if a triangle is valid given its angles.  
   Input:     
   60, 60, 60
   Expected Output:  
   Valid triangle

Q17. Write a Go program to print "Hello" if the input is a specific word ("Hi").  
   Input:     
   Hi
   Expected Output:  
   Hello

Q18. Write a Go program to check if an integer is a two-digit number.  
   Input:     
   34
   Expected Output:  
   34 is a two-digit number

Q19. Write a Go program to check if a number is a prime number.  
   Input:     
   11
   Expected Output:  
   11 is a prime number

Q20. Write a Go program to determine if a number is odd and greater than 10.  
   Input:     
   15
   Expected Output:  
   15 is odd and greater than 10

Q21. Write a Go program to check if a number is divisible by 2, 3, or both.  
   Input:     
   18
   Expected Output:  
   18 is divisible by both 2 and 3

Q22. Write a Go program to check if a character is a digit or not.  
   Input:     
   5
   Expected Output:  
   5 is a digit

Q23. Write a Go program to display a message based on the day of the week.  
   Input:     
   Monday
   Expected Output:  
   Start of the work week!

Q24. Write a Go program to check if a number is greater than 100 or less than 100.  
   Input:     
   120
   Expected Output:  
   120 is greater than 100

Q25. Write a Go program to classify a character as a letter, digit, or special character.  
   Input:     
   @
   Expected Output:  
   @ is a special character

Q26. Write a Go program to find the absolute value of a number.  
   Input:     
   -45
   Expected Output:  
   Absolute value: 45

Q27. Write a Go program to determine if a number is divisible by 7 and ends with 7.  
   Input:     
   77
   Expected Output:  
   77 is divisible by 7 and ends with 7

Q28. Write a Go program to check if a person is eligible to vote based on their age.  
   Input:     
   Age: 19
   Expected Output:  
   Eligible to vote

Q29. Write a Go program to categorize a number as small, medium, or large.  
   Input:     
   45
   Expected Output:  
   Medium

Q30. Write a Go program to determine if a number is a perfect square.  
   Input:     
   49
   Expected Output:  
   49 is a perfect square

Q31. Write a Go program to display the season based on a given month.  
   Input:     
   July
   Expected Output:  
   Summer

Q32. Write a Go program to determine if a number is a multiple of both 4 and 6.  
   Input:     
   24
   Expected Output:  
   24 is a multiple of both 4 and 6

Q33. Write a Go program to check if a number is within a range of 100 to 200.  
   Input:     
   150
   Expected Output:  
   150 is within the range of 100 to 200

Q34. Write a Go program to classify an angle as acute, obtuse, or right.  
   Input:     
   90
   Expected Output:  
   Right angle

Q35. Write a Go program to check if a character is a whitespace character.  
   Input:     
   ' '
   Expected Output:  
   It is a whitespace character

Q36. Write a Go program to check if a person is a teenager based on their age.  
   Input:     
   Age: 16
   Expected Output:  
   The person is a teenager

Q37. Write a Go program to determine if a number is a palindrome.  
   Input:     
   121
   Expected Output:  
   121 is a palindrome

Q38. Write a Go program to calculate the price based on item type (e.g., electronics, clothing).  
   Input:     
   Type: Electronics  
   Price: 1000
   Expected Output:  
   Discounted price: 900

Q39. Write a Go program to check if a triangle is equilateral, isosceles, or scalene.  
   Input:     
   10, 10, 10
   Expected Output:  
   Equilateral triangle

Q40. Write a Go program to determine if a letter is in uppercase or lowercase using ASCII values.  
   Input:     
   f
   Expected Output: 
   f is a lowercase letter

Q41. Write a Go program to print a message if a number is less than, equal to, or greater than 50.  
   Input:     
   50
   Expected Output:  
   The number is equal to 50

Q42. Write a Go program to determine if a number is closer to 0 or 100.  
   Input:     
   30
   Expected Output:  
   Closer to 0

Q43. Write a Go program to print a warning if a speed is above 80.  
   Input:     
   90
   Expected Output:  
   Warning: Speed above 80!

Q44. Write a Go program to assign grades based on a percentage.  
   Input:     
   72
   Expected Output:  
   Grade: B

Q45. Write a Go program to determine if a letter is a consonant.  
   Input:     
   b
   Expected Output:  
   b is a consonant

Q46. Write a Go program to categorize a number as single, double, or triple digits.  
   Input:     
   123
   Expected Output:  
   Triple-digit number

Q47. Write a Go program to calculate a bonus based on years of service.  
   Input:     
   Service: 6 years  
   Salary: 50000
   Expected Output:  
   Bonus: 5000

Q48. Write a Go program to determine if a number is odd and greater than 50.  
   Input:     
   55
   Expected Output:  
   55 is odd and greater than 50

Q49. Write a Go program to display a message for different traffic light signals.  
   Input:     
   Red
   Expected Output:  
   Stop

Q50. Write a Go program to check if a given number is equal to the reverse of itself.  
   Input:     
   121
   Expected Output:  
   121 is equal to its reverse

Q51. Write a Go program to check if a given number is greater than or equal to 50 and less than or equal to 100.  
   Input:     
   75
   Expected Output:  
   75 is in the range 50-100

Q52. Write a Go program to determine the largest even number among three inputs.  
   Input:     
   12, 25, 18
   Expected Output:  
   Largest even number: 18

Q53. Write a Go program to check if a character is a special symbol (e.g., `@`, `#`, `$`).  
   Input:     
   $
   Expected Output:  
   $ is a special symbol

Q54. Write a Go program to determine if a number is divisible by 9 or 11.  
   Input:     
   99
   Expected Output:  
   99 is divisible by 9

Q55. Write a Go program to determine if a given year is a millennium year.  
   Input:     
   2000
   Expected Output:  
   2000 is a millennium year

Q56. Write a Go program to check if a number is divisible by both 4 and 5, or either one.  
   Input:     
   20
   Expected Output:  
   Divisible by both 4 and 5

Q57. Write a Go program to find the smallest positive integer among three numbers.  
   Input:     
   5, -10, 3
   Expected Output:  
   Smallest positive integer: 3

Q58. Write a Go program to check if a number ends with the digit 5.  
   Input:     
   25
   Expected Output:  
   25 ends with 5

Q59. Write a Go program to display a customized message based on the input temperature.  
   Input:     
   35°C
   Expected Output:  
   It's a hot day

Q60. Write a Go program to classify a number as divisible by 3 but not by 5.  
   Input:     
   9
   Expected Output:  
   Divisible by 3 but not by 5

Q61. Write a Go program to determine if a character is an alphabetic letter.  
   Input:     
   k
   Expected Output:  
   k is an alphabetic letter

Q62. Write a Go program to check if a number is negative or zero.  
   Input:     
   -1
   Expected Output:  
   The number is negative

Q63. Write a Go program to display the type of triangle based on its angles.  
   Input:     
   40, 50, 90
   Expected Output:  
   Right-angled triangle

Q64. Write a Go program to display a message based on the type of weather (e.g., sunny, rainy).  
   Input:     
   Rainy
   Expected Output:  
   Take an umbrella

Q65. Write a Go program to check if a number is between 1 and 10 (inclusive).  
   Input:     
   5
   Expected Output:  
   5 is between 1 and 10

Q66. Write a Go program to display a custom message based on the size of a file in MB.  
   Input:     
   120MB
   Expected Output:  
   File size is large

Q67. Write a Go program to find the middle value among three numbers.  
   Input:     
   5, 15, 10
   Expected Output:  
   Middle value: 10

Q68. Write a Go program to determine if the sum of two numbers is even or odd.  
   Input:     
   8, 5
   Expected Output:  
   The sum is odd

Q69. Write a Go program to check if a number lies outside the range of 10 to 20.  
   Input:     
   25
   Expected Output:  
   25 is outside the range of 10 to 20

Q70. Write a Go program to display the time of day based on an hour input (morning, afternoon, evening).  
   Input:     
   9
   Expected Output:  
   Morning

Q71. Write a Go program to categorize the score as Excellent, Good, or Poor.  
   Input:     
   85
   Expected Output:  
   Excellent

Q72. Write a Go program to check if a day is a weekday or weekend.  
   Input:     
   Saturday
   Expected Output:  
   Weekend

Q73. Write a Go program to determine if a number is prime or composite.  
   Input:     
   9
   Expected Output:  
   9 is composite

Q74. Write a Go program to classify a month as having 28, 30, or 31 days.  
   Input:     
   February
   Expected Output:  
   28 or 29 days

Q75. Write a Go program to check if a given name starts with a vowel.  
   Input:     
   Alice
   Expected Output:  
   Alice starts with a vowel

Q76. Write a Go program to check if a number is greater than twice its square root.  
   Input:     
   9
   Expected Output:  
   9 is greater than twice its square root

Q77. Write a Go program to determine if two numbers are equal, one is greater, or one is less.  
   Input:     
   7, 15
   Expected Output:  
   15 is greater than 7

Q78. Write a Go program to display a grade based on the marks scored (90-100: A, 80-89: B, etc.).  
   Input:     
   87
   Expected Output:  
   Grade: B

Q79. Write a Go program to check if a number is both odd and greater than 25.  
   Input:     
   27
   Expected Output:  
   27 is odd and greater than 25

Q80. Write a Go program to determine the largest of four numbers.  
   Input:     
   10, 25, 35, 20
   Expected Output:  
   Largest number: 35

Q81. Write a Go program to display a message based on the current month (e.g., "Holiday season" for December).  
   Input:     
   December
   Expected Output:  
   Holiday season

Q82. Write a Go program to check if a year is divisible by 400, by 100, or by 4.  
   Input:     
   1900
   Expected Output:  
   1900 is divisible by 100 but not by 400

Q83. Write a Go program to categorize a number as single, double, or triple-digit.  
   Input:     
   7
   Expected Output:  
   Single-digit number

Q84. Write a Go program to display a day as a weekday or weekend using a switch statement.  
   Input:     
   Sunday
   Expected Output:  
   Weekend

Q85. Write a Go program to determine if the length of a string is even or odd.  
   Input:     
   "hello"
   Expected Output:  
   Length of "hello" is odd

Q86. Write a Go program to check if a number is divisible by 3 or 7 but not both.  
   Input:     
   21
   Expected Output:  
   21 is divisible by both 3 and 7

Q87. Write a Go program to find the largest odd number among three inputs.  
   Input:     
   11, 8, 13
   Expected Output:  
   Largest odd number: 13

Q88. Write a Go program to determine if a number is positive and divisible by 10.  
   Input:     
   50
   Expected Output:  
   50 is positive and divisible by 10

Q89. Write a Go program to check if the sum of two numbers is greater than 100.  
   Input:     
   60, 45
   Expected Output:  
   The sum is greater than 100

Q90. Write a Go program to display "Pass" or "Fail" based on a score (50 or above is Pass).  
   Input:     
   47
   Expected Output:  
   Fail

Q91. Write a Go program to check if the ASCII value of a character is even or odd.  
   Input:     
   'C'
   Expected Output:  
   ASCII value of 'C' is even

Q92. Write a Go program to determine if a number is divisible by both its digits.  
   Input:     
   36
   Expected Output:  
   36 is divisible by both 3 and 6

Q93. Write a Go program to display a message based on the number of hours worked (e.g., "Overtime" if more than 40 hours).  
   Input:     
   45
   Expected Output:  
   Overtime

Q94. Write a Go program to check if a person is eligible for a senior citizen discount (age >= 60).  
   Input:     
   62
   Expected Output:  
   Eligible for senior citizen discount

Q95. Write a Go program to determine the smallest number among four inputs.  
   Input:     
   10, 5, 8, 12
   Expected Output:  
   Smallest number: 5

Q96. Write a Go program to display a season based on the month using a switch statement.  
   Input:     
   April
   Expected Output:  
   Spring

Q97. Write a Go program to check if a given string starts and ends with the same letter.  
   Input:     
   "level"
   Expected Output:  
   "level" starts and ends with the same letter

Q98. Write a Go program to determine if a number lies between two other numbers inclusively.  
   Input:     
   15, 10, 20
   Expected Output:  
   15 is between 10 and 20

Q99. Write a Go program to check if a number is divisible by the sum of its digits.  
   Input:     
   18
   Expected Output:  
   18 is divisible by the sum of its digits

Q100. Write a Go program to classify a number as a multiple of 5, 10, or neither.  
   Input:     
   50
   Expected Output:  
   50 is a multiple of 10

Share on Social Media