C++ Saved Program: calm-rain

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


#include <stdio.h>
#include<math.h>
#define ACCURACY 0.0001
main()
{
  int n,count;
  float term,sum,x;
  printf("enter the values of x\n");
  scanf("%f", &x);
  n=count=term=sum=1;
  while(n<=100)
  {
      term=term*x/n;
      sum=sum+term;
      count=count+1;
      if(term<ACCURACY)
      n=500;
      else
      n=n+1;
     printf("terms=%d sum=%f\n",count,sum); 

  }

}
 
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs