Tuesday, July 9, 2019

c interview question 22

#include <stdio.h>
#include <stdlib.h>

int main()
{
   int n=8;
    printf("%d\n",func(n));
    return 0;
}



func(int n)
{
    if(n==0)
        return 0;
    else
        return(n+func(n-1));
}

output::
36

No comments:

Post a Comment

python class topic video