/*Problem 1*/
#include<stdio.h>
#include<math.h>
int main()
{
float sum=0,term,sum1,rel_err,a[100];
int N,r,i;
for(i=1;i<=5;i++)
{
printf("Enter the value of an integer N:");
scanf("%d",&N);
for(r=1;r<=N;r++)
{
term=r/((r*r*r)-(r*r)+1.0);
sum=sum+term;
}
a[i]=sum;
sum=0;
printf("The sum is=%.3f\n",a[i]);
}
for(i=1;i<=4;i++)
{
rel_err=(a[i+1]-a[1])*100.0/a[i];
printf("The Relative Error is=%.3f\n",rel_err);
}
return(0);
}
#include<stdio.h>
#include<math.h>
int main()
{
float sum=0,term,sum1,rel_err,a[100];
int N,r,i;
for(i=1;i<=5;i++)
{
printf("Enter the value of an integer N:");
scanf("%d",&N);
for(r=1;r<=N;r++)
{
term=r/((r*r*r)-(r*r)+1.0);
sum=sum+term;
}
a[i]=sum;
sum=0;
printf("The sum is=%.3f\n",a[i]);
}
for(i=1;i<=4;i++)
{
rel_err=(a[i+1]-a[1])*100.0/a[i];
printf("The Relative Error is=%.3f\n",rel_err);
}
return(0);
}
Comments
Post a Comment