# Basic Programming Interview Question Answers
This is a simple collection of problems for interview from the basic knowledge of C programming.
### Part 1: Write Short Procedure or Pseudo-code
---
1. Write a program to print numbers from 1 to 100 without using loops.
2. Write a C program to swap two variables without using a temporary variable.
3. What is the 8 queens problem? Write a C program to solve it?
4. Write a C program to print a square matrix helicaly.
5. Write a C program to reverse a string.
6. Write a C program generate permutations.
7. Write a C program for calculating the factorial of a number.
8. Write a C program to calculate pow(x,n)?
9. How do you calculate the maximum sum of a list of numbers?
10. How to generate fibonacci numbers with recurison? Can you optimize it?
11. Solve the Rat In A Maze problem using backtracking.
12. Write C code to solve the Tower of Hanoi problem (generalize form).
13. Write a C program which produces its own source code as its output.
14. Write a C program to convert from decimal to any base (binary, hex, oct etc…).
15. Write C code to check if an integer is a power of 2 or not in a single line?
16. Write a C program to find the GCD of two numbers.
17. Write code to remove duplicates in a sorted array.
18. Find the maximum of three integers using the ternary operator.
19. Write C code to dynamically allocate one, two and three dimensional arrays (using malloc()).
20. How would you find the size of structure without using sizeof()?
21. Write a C program to multiply two matrices.
22. Write a C program to check for palindromes.
23. Write a C program to convert a decimal number into a binary number.
24. Write C code to implement the Binary Search algorithm.
25. How do you compare floating point numbers?
26. Write a program to check if a given year is a leap year or not?
27. Is there something we can do in C but not in C++?
28. Can you write general sieve method for finding prime numbers?
29. What is the difference between scanf(“%s”, str) and gets(str)?
30. Write your own sqrt() function in C.
31. How can we sum the digits of a given number in single statement?
---
### Part 2: Find The Output
---
**1. Find the output –**
```c++
int counter = 0, i;
for(i=0;;i++) {
if (i<100) continue;
counter ++;
if (counter == 100) break;
}
printf(%d%d”,i, counter);
```
**2. What is the value of EOF..??**
Ans: -1
**3. What is the output?**
```c++
class test{ };
int main()
{
cout<