Practice Top C Programming Questions on Callback Function, TechnoVlogs

Practice Top C Programming Questions on Callback Function


Q1. Write a program where a callback function prints "Hello, World!".

Input: (None)  
Output: Hello, World!

Q2. Use a callback function to sort an array in ascending order.

Input: 4 2 5 1  
Output: 1 2 4 5

Q3. Write a program that uses a callback function to add two numbers.

Input: 5 7  
Output: 12

Q4. Write a callback function to subtract two numbers.

Input: 10 4  
Output: 6

Q5. Write a callback function to compare two integers and return the larger number.

Input: 8 3  
Output: 8

Q6. Use a callback function to check if two strings are equal.

Input: "abc" "abc"  
Output: Equal

Q7. Write a callback function that calculates the square of a number.

Input: 6  
Output: 36

Q8. Use a callback function to multiply two numbers.

Input: 3 9  
Output: 27

Q9. Filter an array of integers to keep only even numbers using a callback function.

Input: 1 2 3 4 5  
Output: 2 4

Q10. Write a program that uses a callback function to calculate the factorial of a number.

Input: 5  
Output: 120

Q11. Write a callback function to concatenate two strings.

Input: "Hello" "World"  
Output: HelloWorld

Q12. Use a callback function to calculate the sum of all elements in an array.

Input: 2 4 6  
Output: 12

Q13. Write a callback function to find the largest element in an array.

Input: 5 9 3  
Output: 9

Q14. Use a callback function to sort an array in descending order.

Input: 1 4 3 2  
Output: 4 3 2 1

Q15. Write a program that applies a callback function to square each element in an array.

Input: 1 2 3  
Output: 1 4 9

Q16. Write a callback function to calculate the length of a string.

Input: "Programming"  
Output: 11

Q17. Write a callback function to count vowels in a string.

Input: "Education"  
Output: 5

Q18. Write a callback function to find the smallest number in an array.

Input: 7 3 8  
Output: 3

Q19. Write a callback function to reverse a string.

Input: "CProgramming"  
Output: gnimmargorPC

Q20. Use a callback function to check if a string is a palindrome.

Input: "radar"  
Output: Palindrome

Q21. Write a callback function to calculate the power of a number.

Input: 2 3  
Output: 8

Q22. Use a callback function to check if a number is prime.

Input: 17  
Output: Prime

Q23. Write a callback function to determine which string is lexicographically smaller.

Input: "apple" "banana"  
Output: apple

Q24. Use a callback function to divide two numbers.

Input: 10 2  
Output: 5

Q25. Write a callback function to swap two integers.

Input: 3 7  
Output: 7 3

Q26. Write a callback function to count occurrences of a character in a string.

Input: "hello" 'l'  
Output: 2

Q27. Use a callback function to filter positive numbers from an array.

Input: -1 4 -3 2  
Output: 4 2

Q28. Write a callback function to convert a string to uppercase.

Input: "hello"  
Output: HELLO

Q29. Use a callback function to calculate the product of elements in an array.

Input: 1 2 3  
Output: 6

Q30. Write a callback function to check if a number is odd.

Input: 11  
Output: Odd

Social Share

Bikki Singh Instructor TechnoVlogs

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!