Evaluation of eX Series - C Program

Program:
#include<stdio.h>
//#include<conio.h>
void ex(int y,int n)
{
    int i;
    float term=1,sum=1;
    for(i=1;i<=n;i++)
    {
        term=((term)*y)/(i);
        sum=sum+term;
    }
    printf("Sum of the ex series=%f\n",sum);
 }
void main()
{
     int n,y;
     float x;//clrscr();
     printf("Enter the no of terms:");
     scanf("%d",&n);
     printf("Enter the value:");
     scanf("%f",&x);
     ex(x,n);
    // getch();
}

Output:
nn@linuxmint ~ $ gcc c13.c
nn@linuxmint ~ $ ./a.out
Enter the no of terms:10
Enter the value:30
Sum of the ex series=238829632.000000
nn@linuxmint ~ $

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...