Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Mathematics ProgramRSS Feeds

PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES. 1 + 2 + 6 + 24 + 120 + ......

Posted By: Ollie Moreno     Category: C Programming     Views: 4523

WRITE A PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES.
INPUT STEPS FROM KEYBOARD.
1 + 2 + 6 + 24 + 120 + ......

Code for PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES. 1 + 2 + 6 + 24 + 120 + ...... in C Programming

#include<stdio.h>
#include<conio.h>
void main()
{
        longint fact=1,i,n,sum=0;
        clrscr();
        printf("\n ENTER THE VALUE OF N: ");
        scanf("%ld",&n);
        printf("\n THE SERIES IS ");
        for(i=1;i<=n;i++)
        {
            fact = fact * i;
            if(i==n)
                printf(" %ld",fact);
            else
                printf("%ld + ",fact);
                sum = sum + fact;
        }

        printf("\n**************************************");
        printf("\nTHE FACTORIAL VALUE IS %ld the sum is %ld",fact,sum);
        printf("\n**************************************");
        getch();

}

********************************* OUTPUT ***********************


     ENTER THE VALUE OF N: 5

     THE SERIES IS 1 + 2 + 6 + 24 +  120

     THE FACTORIAL VALUE IS 120 the sum is 153


****************************************************************
  
Share: 



Ollie Moreno
Ollie Moreno author of PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES. 1 + 2 + 6 + 24 + 120 + ...... is from Los Angeles, United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!