GATE | GATE-CS-2015 (Mock Test) | Question 2

Last Updated :
Discuss
Comments
The output of following C program is C
#include <stdio.h>
char str1[100];

char *fun(char str[])
{
    static int i = 0;
    if (*str)
    {
        fun(str+1);
        str1[i] = *str;
        i++;
    }
    return str1;
}

int main()
{
    char str[] = "GATE CS 2015 Mock Test";
    printf("%s", fun(str));
    return 0;
}
GATE CS 2015 Mock Test
tseT kcoM 5102 SC ETAG
Nothing is printed on screen
Segmentation Fault
Share your thoughts in the comments