Practice Top 30 C Programming Questions on Function
Q1. Write a function to add two numbers and return the result.
Input: 5 10
Output: 15
Q2. Create a function that takes an integer and returns its square.
Input: 7
Output: 49
Q3. Write a function to convert a Fahrenheit temperature to Celsius.
Input: 98.6
Output: 37.00
Q4. Write a function to check if a number is even or odd.
Input: 9
Output: Odd
Q5. Write a function to find the maximum of two numbers.
Input: 3 8
Output: 8
Q6. Write a function to calculate the factorial of a given number.
Input: 5
Output: 120
Q7. Write a function to swap two numbers without using a temporary variable.
Input: 4 7
Output: 7 4
Q8. Write a function to find the smallest among three numbers.
Input: 5 3 8
Output: 3
Q9. Write a function to calculate simple interest based on principal, rate, and time.
Input: 1000 5 2
Output: 100
Q10. Write a function to check if a given character is a vowel.
Input: a
Output: Vowel
Q11. Write a function to reverse a number.
Input: 1234
Output: 4321
Q12. Write a function to check whether a number is prime or not.
Input: 7
Output: Prime
Q13. Write a function to calculate the sum of digits of a number.
Input: 123
Output: 6
Q14. Write a function to find the greatest common divisor (GCD) of two numbers.
Input: 12 15
Output: 3
Q15. Write a function to calculate \( a^b \) (a raised to the power b).
Input: 2 3
Output: 8
Q16. Write a function to check if a number is a palindrome.
Input: 121
Output: Palindrome
Q17. Write a function to find the length of a given string.
Input: Hello
Output: 5
Q18. Write a function to check if a number is an Armstrong number.
Input: 153
Output: Armstrong
Q19. Write a function to count the number of vowels in a string.
Input: Education
Output: 5
Q20. Write a function to calculate the area of a circle given its radius.
Input: 7
Output: 153.94
Q21. Write a function to generate the first N Fibonacci numbers.
Input: 5
Output: 0 1 1 2 3
Q22. Write a function to check if a year is a leap year.
Input: 2020
Output: Leap Year
Q23. Write a function to find the sum of elements in an array.
Input: 1 2 3 4 5
Output: 15
Q24. Write a function to check if a number is a perfect number.
Input: 28
Output: Perfect
Q25. Write a function to find the largest element in an array.
Input: 3 1 4 1 5
Output: 5
Q26. Write a function to reverse a string.
Input: Hello
Output: olleH
Q27. Write a function to count the number of words in a string.
Input: Hello World
Output: 2
Q28. Write a function to check if a number is a perfect square.
Input: 16
Output: Perfect Square
Q29. Write a function to find the sum of the first N natural numbers.
Input: 10
Output: 55
Q30. Write a function to check if a number is positive.
Input: -5
Output: Negative
Bikki Singh
Hi, I am the instructor of TechnoVlogs. I have a strong love for programming and enjoy teaching through practical examples. I made this site to help people improve their coding skills by solving real-world problems. With years of experience, my goal is to make learning programming easy and fun for everyone. Let's learn and grow together!