Skip to content
Related Articles

Related Articles

Improve Article

Algorithms Quiz | SP Contest 1 | Question 6

  • Difficulty Level : Hard
  • Last Updated : 11 Jul, 2018

What is the output of below C program?




#include <stdio.h>
  
void print(int c){
      
    if (c < 0) {
        return;
    }
      
    printf("%d ", c);
    c--;
    print(c);
      
    c++;
      
    printf("%d ", c);
  
}
  
int main() {
   int c = 5;
   print(c);
   return 0;    

(A) 5 4 3 2 1 0 0 0 1 2 3 4
(B) 5 4 3 2 1 0 0 1 2 3 4 5
(C) 1 2 3 4 5 0 0 5 4 3 2 1
(D) 5 4 3 2 1 1 0 1 2 3 4 5


Answer: (B)

Explanation:

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :