#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int i, x, n;
float sum, p;
clrscr();
printf("Enter the base value 'x':");
scanf("%d", &x);
printf("\nEnter the power value 'n':");
scanf(" %d", &n);
sum=1;
for( i=1; i<=n ; i++)
{
p=pow(x, i);
sum=sum+(1/p);
}
printf("\nSum of the series: %f", sum);
getch( );
}
#include<conio.h>
#include<math.h>
void main()
{
int i, x, n;
float sum, p;
clrscr();
printf("Enter the base value 'x':");
scanf("%d", &x);
printf("\nEnter the power value 'n':");
scanf(" %d", &n);
sum=1;
for( i=1; i<=n ; i++)
{
p=pow(x, i);
sum=sum+(1/p);
}
printf("\nSum of the series: %f", sum);
getch( );
}
No comments:
Post a Comment