20 Basic C Programming Questions (With
Explanations)
1. Write a program to add two numbers entered by the user.
2. Write a program to find the square and cube of a given number.
3. Write a program to swap two numbers using a third variable.
4. Write a program to calculate simple interest (SI = P × R × T / 100).
5. Write a program to find the average of three numbers.
6. Write a program to check whether a number is positive or negative.
7. Write a program to check whether a number is even or odd.
8. Write a program to find the largest of two numbers.
9. Write a program to find the largest of three numbers.
10. Write a program to check whether a character is a vowel or consonant.
11. Write a program to print the first 10 natural numbers using a loop.
12. Write a program to print the sum of first N natural numbers (N given by user).
13. Write a program to generate the multiplication table of a given number.
14. Write a program to calculate the factorial of a given number.
Example: Factorial of 5 = 5 × 4 × 3 × 2 × 1 = 120.
15. Write a program to check whether a given number is a palindrome or not.
Palindrome: A number that reads the same forward and backward.
Example: 121 is a palindrome (reverse is also 121).
16. Write a program to reverse a given number.
Example: If input is 1234, output should be 4321.
17. Write a program to check whether a given number is an Armstrong number or not.
Armstrong Number: A number whose sum of cubes of its digits equals the number itself.
Example: 153 → 1³ + 5³ + 3³ = 153.
18. Write a program to check whether a given number is a perfect number or not.
Perfect Number: A number equal to the sum of its proper divisors (excluding itself).
Example: 28 → Divisors: 1 + 2 + 4 + 7 + 14 = 28.
19. Write a program to find the sum of digits of a given number.
Example: 1234 → 1 + 2 + 3 + 4 = 10.
20. Write a program to print Fibonacci series up to N terms.
Fibonacci Series: A series where each number is the sum of the previous two.
Example: 0, 1, 1, 2, 3, 5, 8, 13...