Write a program to calculate the following series:

Write a program to calculate the following series: S=1!+2!+3!+4!+..............................+n.

  • Sree
  • 09 अप्रैल
  • 1 उत्तर

1 उत्तर
1-1 of  1
1 Answer
  • #include<stdio.h>
    int add(int num)
    {
    int i,j,fact,sum=0;
    for(i=1;i<=num;i++)//loop for finding factorial and sum
    {
    fact=1;
    if(i!=num)
    printf("%d!+ ",i);
    else
    printf("%d!= ",i);
    for(j=1;j<=i;j++)
    fact=fact*j;
    sum=sum+fact;
    }
    return sum;
    }
    int main()
    {
    int num;
    printf("Enter the last number of series:\n");
    scanf("%d",&num);//last number of series
    printf("%d",add(num));
    return 0;
    }
    -1

c programming
मॉक परीक्षण अभ्यास के लिए
c programming