Write a C program to Calculate the below Series. The Value of x and n must take from input terminal.
#include<stdio.h>
#include<conio.h>
main()
{
int i,x,n,j;
float sum=0.0,a=1.0,r,y;
printf("Enter the value of X:");
scanf("%d",&x);
printf("\nEnter the range value for series:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
y=a/i;
r=x*y;
sum=sum+r;
}
printf("\nThe sum is:");
printf("%f\n",sum);
}
No comments:
Post a Comment