why is it giving wrong answer

#include <stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t>0)
{
int n,i,f;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
f=f*i;

    }
    printf("%d\n",f);
    f=1;
    t--;
}
return 0;

}

You have not initialized f variable… write like this


int n,i,f = 1;

Please mark this answer as accepted if you found it useful