Programming Fundamental Interview
Questions
This document contains common programming fundamental questions often asked
in interviews. These questions test basic logic, string manipulation, array
operations, and problem-solving skills.
Basic Programming & Logic Questions
1. Swap two numbers without using a third variable
2. Check if a number is prime
3. Reverse a string
4. Check if a string is a palindrome
5. Find factorial of a number (using recursion and iteration)
6. Find Fibonacci series up to N terms
7. Check if two strings are anagrams
8. Count vowels and consonants in a string
9. Find largest and smallest element in an array
10. Sum of digits of a number
Intermediate Logic Questions
11. Find the missing number in an array (numbers from 1 to n)
12. Check if a number is Armstrong
13. Find duplicate elements in an array
14. Sort an array without using built-in functions (Bubble Sort, Selection Sort,
Insertion Sort)
15. Remove duplicates from a string or array
16. Find the second largest element in an array
17. Print pattern programs (e.g., *, **, ***)
18. Reverse an array in place
String & Array Manipulation
19. Check if two strings are rotations of each other
20. Find first non-repeating character in a string
21. Find the frequency of characters in a string
22. Implement basic string compression (e.g., aaabbcc → a3b2c2)
Additional Questions
23. Create and manipulate a 2D array (Matrix operations)
24. Create and manipulate a 3D array (Access and modify elements)
25. Write a function to validate email without using filter_var
26. Explain the difference between == and === in PHP
27. Reverse words in a sentence (e.g., 'I love PHP' → 'PHP love I')