11. Implement a program to find the factorial of a number using recursion.

Required Input:

number = 5

Expected Output:

Factorial = 120

Code In C

#include int factorial(int n); int main() { int number = 5; // Logic to calculate factorial return 0; }

Output

Click Run Button to view compiled output

12. Create a program to implement binary search on a sorted array.

Required Input:

arr = {1, 2, 3, 4, 5}, target = 3

Expected Output:

Element found at index 2

Code In C

#include int binarySearch(int arr[], int size, int target); int main() { int arr[] = {1, 2, 3, 4, 5}; int target = 3; // Logic to perform binary search return 0; }

Output

Click Run Button to view compiled output

13. Write a program to check if a string is a palindrome using pointers.

Required Input:

str = 'madam'

Expected Output:

madam is a palindrome

Code In C

#include #include int main() { char str[] = "madam"; // Logic to check if the string is a palindrome return 0; }

Output

Click Run Button to view compiled output

14. Implement a program to find the GCD (Greatest Common Divisor) of two numbers using recursion.

Required Input:

a = 48, b = 18

Expected Output:

GCD = 6

Code In C

#include int gcd(int a, int b); int main() { int a = 48, b = 18; // Logic to find GCD return 0; }

Output

Click Run Button to view compiled output

15. Write a program to count the occurrences of a character in a string using pointers.

Required Input:

str = 'hello world', ch = 'o'

Expected Output:

Occurrences of 'o' = 2

Code In C

#include int main() { char str[] = "hello world"; char ch = 'o'; // Logic to count occurrences return 0; }

Output

Click Run Button to view compiled output

16. Implement a program to swap two integers using pointers.

Required Input:

a = 5, b = 10

Expected Output:

After swapping: a = 10, b = 5

Code In C

#include void swap(int *x, int *y); int main() { int a = 5, b = 10; // Logic to swap using pointers return 0; }

Output

Click Run Button to view compiled output

17. Create a program to find the longest word in a sentence.

Required Input:

sentence = "Write a C program to find the longest word"

Expected Output:

Longest word = program

Code In C

#include #include int main() { char sentence[] = "Write a C program to find the longest word"; // Logic to find the longest word return 0; }

Output

Click Run Button to view compiled output

18. Write a program to check if two strings are anagrams of each other.

Required Input:

str1 = 'listen', str2 = 'silent'

Expected Output:

The strings are anagrams.

Code In C

#include #include void checkAnagram(char str1[], char str2[]); int main() { char str1[] = "listen"; char str2[] = "silent"; // Logic to check for anagrams return 0; }

Output

Click Run Button to view compiled output

19. Implement a program to perform basic arithmetic operations on two numbers using function pointers.

Required Input:

a = 10, b = 5

Expected Output:

Sum = 15
Difference = 5
Product = 50
Quotient = 2

Code In C

#include typedef int (*operation)(int, int); int add(int a, int b); int subtract(int a, int b); int multiply(int a, int b); int divide(int a, int b); int main() { int a = 10, b = 5; // Logic to perform operations using function pointers return 0; }

Output

Click Run Button to view compiled output

20. Create a program to find the second largest number in an array.

Required Input:

arr = {5, 3, 8, 1, 4}

Expected Output:

Second Largest Element = 5

Code In C

#include int main() { int arr[] = {5, 3, 8, 1, 4}; int size = sizeof(arr) / sizeof(arr[0]); // Logic to find second largest return 0; }

Output

Click Run Button to view compiled output

ad vertical

2 of 3