void foo(int n, int sum) {
int k = 0, j = 0;
if (n == 0) return;
k = n % 10;
j = n / 10;
sum = sum + k;
foo(j, sum);
printf("%d, ", k);
}
int main() {
int a = 2048, sum = 0;
foo(a, sum);
printf("%d\n", sum);
getchar();
}Related Programming & Data Structures PYQs
Consider the following C-program: ```c double foo(double); /* Line 1 */ int main() { double da, db; // input da db = f…
What does the following C-statement declare? int (*f)(int *);
Postorder traversal of a given binary search tree, T produces the following sequence of keys: 10, 9, 23, 22, 27, 25, 15, 50, 95, 6…
How many distinct binary search trees can be created out of 4 distinct keys?
In a complete k-ary tree, every internal node has exactly k children. The number of leaves in such a tree with n internal nodes is…
Which data structure is inherently used by the operating system / runtime environment to execute recursive function calls?
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.