#include <stdio.h>
int f(int *a, int n) {
if (n <= 0) return 0;
else if (*a % 2 == 0)
return *a + f(a + 1, n - 1);
else
return *a - f(a + 1, n - 1);
}
int main() {
int a[] = {12, 7, 13, 4, 11, 6};
printf("%d", f(a, 6));
getchar();
return 0;
}Related Programming & Data Structures PYQs
The following C function takes a singly-linked list as input argument. It modifies the list by moving the last element to the fron…
In a binary tree with n nodes, every node has an odd number of descendants. Every node is considered to be its own descendant. Wha…
Let n be an odd number greater than 100. Consider a binary minheap with n elements stored in an array P whose index starts from 1.…
Consider a hash table P[0, 1, ..., 10] that is initially empty. The hash table is maintained using open addressing with linear pro…
The height of a binary tree is the number of edges in the longest path from the root to a leaf in the tree. The maximum possible h…
Consider the following program in C: ```c #include <stdio.h> void func(int i, int j) { if(i < j) { int i = 0; while (i <…
Free account benefits
Turn practice into measurable progress
Public PYQs and reference pages stay free. Sign in when you want GATEverse to remember what you studied and guide what to practise next.