C Programming - Pointers - Discussion

Discussion Forum : Pointers - Point Out Correct Statements (Q.No. 8)
8.
In the following program add a statement in the function fact() such that the factorial gets stored in j.
#include<stdio.h>
void fact(int*);

int main()
{
    int i=5;
    fact(&i);
    printf("%d\n", i);
    return 0;
}
void fact(int *j)
{
    static int s=1;
    if(*j!=0)
    {
        s = s**j;
        *j = *j-1;
        fact(j);
        /* Add a statement here */
    }
}
j=s;
*j=s;
*j=&s;
&j=s;
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
28 comments Page 3 of 3.

Deepika said:   8 years ago
Please, anyone explain clearly.

Udam said:   1 decade ago
Why j=&s is not workings?

SAHA said:   4 years ago
Wow. Nice explanation @Jas.

Abhishek said:   7 years ago
Explain it clearly for me.

Akash said:   7 years ago
The answer should be j=s.

Rahul said:   1 decade ago
What does s**j mean?

Mayur baviskar said:   4 years ago
Thanks @Kareena.

Shivu said:   9 years ago
Thanks @R K.


Post your comments here:

Your comments will be displayed after verification.