/* Theory:Recursion is a programming technique where a function calls itself to solve a problem. It breaks down complex problems into simpler, smaller instances of the same problem. Each recursive call progresses towards a base case, which stops the recursion. It’s commonly used in tasks like sorting, searching, and traversing data structures. Properly defined base cases are essential to prevent infinite loops. */ //Write a program to compute an mod m #include #include using namespace std; int exponentMod(int A, int B, int C) { if (A == 0) return 0; if (B == 0) return 1; long y; if (B % 2 == 0) { y = exponentMod(A, B / 2, C); y = (y * y) % C; } else { y = A % C; y = (y * exponentMod(A, B - 1, C) % C) % C; } return (int)((y + C) % C); } int main() { int b = 12, n = 2, m = 5; printf(" %d^%d mod %d = %d",b,n,m,exponentMod(b, n, m)); return 0; } // Program 2 //binary search recursion #include #include int binSearch(int arr[],int key,int l,int r); int main() { int arr[] = {11,12,13,14,15,16,17,18,19,20}; int key=19; int pos = binSearch(arr,key,0,10); if(pos<0) printf("Key item not found"); else printf("Key item found at location %d\n",pos); getch(); return 0; } int binSearch(int arr[],int key, int l,int r) { if(l