Logo 
Search:

C Programming Articles

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

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

Posted By: Isla Hughes     Category: C Programming     Views: 1922

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. INPUT STEPS FROM KEYBOARD. 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("\nTHE FACTORIAL VALUE IS %ld the sum is %ld",fact,sum);
    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


*********************************************************/* NAME:NAYAN SHAH
ROLL NO: 48
SEMISTER: 1
DEFINATION: WRITE A PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES.
INPUT STEPS FROM KEYBOARD.

1 + 2 + 6 + 24 + 120 + ......

*/
#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(); }
  
Share: 



Isla Hughes
Isla Hughes author of PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES. INPUT STEPS FROM KEYBOARD. 1 + 2 + 6 + 24 + 120 + ...... is from London, United Kingdom.
 
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!