can anyone help me with hoe to store the value of "c" into the A[160] ??

#include<stdio.h>
int main()
{
int t,i,j,n;
printf(“Enter the test case:\n”);
scanf("%d",&t);
int A[160],c=1;
while(t>0)
{
printf(“Enter the number:\n”);
scanf("%d",&n);
c=1;
for(i=1;i<=n;i++)
{
c=c*i;
}
printf("%d\n",c);
t–;
}
return 0;
}

A[i]=c;

where ‘i’ is index of array where you want to store.

in your for loop use A[i]=c;

also use double instead of int as it will give garbage value if u give big value as input…

Here is Sample code of your program

#include<stdio.h>
int main()
{ int t,i,j,n;
printf("Enter the test case:\n");
scanf("%d",&t);
double A[160],c=1;
 while(t>0)
 {
printf("Enter the number:\n");
 scanf("%d",&n);
 c=1;
 for(i=1;i<=n;i++)
    {
    c=c*i;
    A[i]=c;
    }
 printf("%d\n",c);
 printf("Show Array Position\n");
 for(i=1;i<=n;i++)
 {
     printf("%d\t",i);
     printf("%d\n",A[i]);
 }
 printf("\n");
 t--;
 }
 return 0;
 }

thanx all :slight_smile:

you will also want to declare the size of the array one more than the last index you wish to access. In this case A[161] to be precise (even though c,cpp will allow access of memory beyond allocated memory - that is just a horrible practice).