/* sum of factorials in between m and n */
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, m, n, fact=1, sum=0;
clrscr();
printf("\n Enter the starting and ending point :");
scanf("%d%d", &m, &n);
for(i=m ;i<=n ;i++)
{
fact=1;
for(j=1; j<=i; j++)
{
fact = fact * j ;
}
sum = sum + fact;
}
printf("\n The sum of factorials between %d and %d is:
%d", m, n, sum);
getch();
}
No comments:
Post a Comment