search
Log In
2 votes
231 views
void foo(int n)
{
    for(i1=1;i1<=n;i1++)
    {
        for(i2=1;i2<=i1;i2++)
        {
            .......
            {
                for(i6=1;i6<=i5;i6++)
                {
                    count++;
                }
            }
        }
    }
}

Count initially 0.What is value returned by foo(8)?

in Programming
edited by
231 views
1
$\frac{n*(n+1)*(n+2)*(n+3)*(n+4)*(n+5)}{1.2.3.4.5.6}$

is this the answer ?
0

yes ans $\binom{13}{6}$

how u done

plz tell procedure @Shobhit Joshi

5
$S_1=n$ , if there was only $1$ for loop

$S_2=\sum_{1}^{n} n=\frac{n*(n+1)}{1*2}$ , if there were $2$ for loop

$S_3=\sum_{1}^{n}S_2=\frac{n*(n+1)*(n+2)}{1*2*3}$ , if there were $3$ for loop

similarly, $S_6=\sum_{1}^{n}S_5=\frac{n*(n+1)*(n+2)*(n+3)*(n+4)*(n+5)}{1*2*3*4*5*6}$ , if there were $6$ for loop

That's how i did it
0

@Shobhit Joshi's answer is nice.

I just want to add that, this type of loop is a general form for computing (n+r-1)C(r), here n=8, r=6.

0

@aambazinga thanks, i will try to remember !

0
1716 is the answer....

Please log in or register to answer this question.

Related questions

0 votes
2 answers
1
0 votes
0 answers
2
216 views
Consider the following C code: #include <stdio.h> struct MadeEasy { char p,q,r; }; int main (void) { struct MadeEasy a={ d' - 2019,'e',5+'a'}; struct MadeEasy *b=&a; printf("%c, %c", *((char*)b+1)- 1, *((char*)b+ 2)- 1); return 0; } The output of the following code will be
asked Jan 29, 2019 in Programming Ram Swaroop 216 views
2 votes
2 answers
4
178 views
char *a = “MADEEASY”; char *b = “GATECSIT2019”; char *r = a; char *s = b; printf(“%d”, (int) strlen (b+3[r] – 1[s])); return 0; Whats the output? Answer given 8
asked Dec 11, 2018 in Programming Shamim Ahmed 178 views
...