Recursion
Study notes are awaiting editorial approval. You can still practise the reviewed questions below.
Related previous-year questions
Practise this topic- 2026 · Consider the recursive functions represented by the following code segment: ```c int bar(int n){ if (n == 1) return 0; else return 1 + bar(n/2); }
- 2026 · Consider the following ANSI-C function. ```c int func(int start, int end){ int length=end+1-start; if((length<1)||(start<0)||(end<0)){ return(0); }
- 2025 · ```c #include <stdio.h> int foo(int S[],int size){ if(size == 0) return 0; if(size == 1) return 1; if(S[0] != S[1]) return 1+foo(S+1,size-1); retu
- 2025 · Consider the following C program: ```c #include <stdio.h> int g(int n) { return (n+10); } int f(int n) { return g(n*2); } int main() { in
- 2024 · Consider the following C program: ```c #include <stdio.h> void fX(); int main(){ fX(); return 0; } ------------------------ void fX(){ char a; if((a
- 2023 · Consider the following program: ```c int main() { f1(); f2(2); f3(); return(0); } int f1() { return(1); } int f2(int X) { f3(); if (X==1) return f1()
- 2021 · Consider the following ANSI C function: ```c int SomeFunction(int x, int y) { if ((x == 1) || (y == 1)) return 1; if (x == y) return x; i
- 2021 · Consider the following ANSI C program: ```c #include <stdio.h> int foo(int x, int y, int q) { if ((x <= 0) && (y <= 0)) return q; if
- 2020 · Consider the following C functions. ```c int fun1(int n) { static int i = 0; if (n > 0) { ++i; fun1(n-1); } return(i)
- 2019 · Consider the following C function: ```c void convert(int n){ if(n<0) printf("%d",n); else { convert(n/2); printf("%d",
- 2018 · Consider the following C program: ```c #include <stdio.h> int counter = 0; int calc (int a, int b) { int c; counter++; if (b==3) return (a*a*a); e
- 2018 · Consider the following C code. Assume that unsigned long int type length is 64 bits. ```c unsigned long int fun(unsigned long int n){ unsigned long i