Open In App

Algorithms Quiz | SP Contest 1 | Question 6

Like Article
Like
Save
Share
Report

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


Last Updated : 11 Jul, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads