PHP

20+ Programming Problems on Control Statements in PHP

The following post provides 20+ Programming Problems on Control Statements in PHP. Also, the solutions are available on respective links.

  1. Print numbers from 45 to 225 using a for loop.
  2. Then, print even numbers from 7 to 120 using a for loop.
  3. Also, print odd numbers from 9 to 155 using a while loop.
  4. Find the sum of all even numbers from 12 to 230 using a for loop.
  5. Also, find the sum of all odd numbers from 56 to 981 using a while loop.
  6. Check if a number is even or odd.
  7. Also, check if a number is prime or not.
  8. Print the Fibonacci series up to a given number.
  9. Find the factorial of a given number using a for loop.
  10. Also, find the factorial of a given number using a while loop.
  11. Check a string for palindrome.
  12. Print the multiplication table of a given number.
  13. Compute the GCD of two numbers using any loop.
  14. Also, find the LCM of two numbers using any loop.
  15. Print the ASCII values of all characters from A to Z.
  16. Perform decimal to binary conversion.
  17. Also, perform binary to decimal conversion.l.
  18. Reverse a given string.
  19. Find the largest and smallest numbers in an array.
  20. Check if an array is sorted in ascending order.
  21. Also, check if an array is sorted in descending order.
  22. Remove all the negative numbers from an array.
  23. Find the average of all the elements in an array.
  24. From an integer array, find the second-largest element.
  25. Display the Fibonacci series up to 10 terms.
  26. Calculate the sum of the digits of a given number.
  27. Reverse a given number.
  28. Print the sum of the first 65 natural numbers.
  29. Also, print the sum of the first 45 even numbers.
  30. Find the largest among the three given numbers.
  31. Also, find the smallest among the three given numbers.
  32. Check if a given string is a palindrome or not.
  33. Display, from a specific string,
    1. how many vowels are there?
    2. Also, display, how many words are there.
    3. Print the ASCII value of all characters.
    4. Find the length of the longest word.
  34. Remove all whitespace from a given string.
  35. Convert a given string to uppercase.
  36. Also, convert a given string to lowercase.
  37. Replace all occurrences of a given substring in a string with another substring.
  38. Display the first n prime numbers.
  39. Compare three numbers to find the largest using the ternary operator.
  40. Display the Fibonacci series up to a given value of the term.
  41. Print the multiplication table of a given number.
  42. Also, print the ASCII values of all the characters in a string.
  43. From an integer array, get the second largest element.
  44. Likewise, get the second smallest element.
  45. Sort an array of integers in ascending order using bubble sort.
  46. Also, sort an array of integers in descending order using selection sort.
  47. Find the sum of all even numbers in an array.
  48. Also, find the sum of all odd numbers in an array.
  49. Then, find the average of an array of numbers.
  50. Also, find the mode of an array of numbers.
  51. Find the median of an array of numbers.
  52. Print a pattern of stars in a pyramid shape.
  53. Also, print a pattern of numbers in a pyramid shape.
  54. Then, print a pattern of alphabets in a pyramid shape.
  55. Further, print a pattern of stars in a right-angled triangle shape.
  56. Then, print a pattern of numbers in a right-angled triangle shape.
  57. Next, print a pattern of alphabets in a right-angled triangle shape.
  58. Print a pattern of stars in an inverted pyramid shape.
  59. Also, print a pattern of numbers in an inverted pyramid shape.
  60. Next, print a pattern of alphabets in an inverted pyramid shape.
  61. Print a pattern of stars in a diamond shape.
  62. Then, print a pattern of numbers in a diamond shape.
  63. Next, print a pattern of alphabets in a diamond shape.
  64. Also, print a pattern of stars in a hollow square shape.
  65. Print a pattern of numbers in a hollow square shape.
  66. Then, print a pattern of alphabets in a hollow square shape.
  67. Next, print a pattern of stars in a hollow triangle shape.
  68. Also, print a pattern of numbers in a hollow triangle shape.
  69. Display a pattern of alphabets in a hollow triangle shape.
  70. Print a pattern of stars in a hollow diamond shape.
  71. Then, print a pattern of numbers in a hollow diamond shape.
  72. Next, print a pattern of alphabets in a hollow diamond shape.
  73. Also, print a pattern of stars in a rectangle shape.
  74. Display a pattern of numbers in a rectangle shape.
  75. Print a pattern of alphabets in a rectangle shape.
  76. Then, print a pattern of stars in a hollow rectangle shape.
  77. Next, print a pattern of numbers in a hollow rectangle shape.
  78. Print a pattern of alphabets in a hollow rectangle shape.

Further Reading

10+ File Handling Problems in PHP

Pattern Display Problems in PHP

Examples of Array Functions in PHP

Exploring PHP Arrays: Tips and Tricks

Basic Programs in PHP

Exploring Arrays in PHP

programmingempire

princites.com

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *