Contact Learn C
Copy

Program 298: Display Series in AP along with Sum for given Common difference and Number of Terms

Program 298: Display Series in AP along with Sum for given Common difference and Number of Terms
 
#include<stdio.h>
main()
{ 
//an=a+(n-1)d
  int i,n;
  float sum=0,num1,diff,lastnum,seriesFirstNum;
  
  printf("Enter first number of the series\n");
  scanf("%f",&num1);
  printf("Enter Common difference\n");
  scanf("%f",&diff);
  printf("Enter number of terms in the series\n");
  scanf("%d",&n);
  seriesFirstNum=num1;
lastnum=(float)(num1+((n-1)*diff));  
  for(i=1;i<=n;i++)
  {
   sum+=seriesFirstNum;
   seriesFirstNum+=diff;
  }
  
  seriesFirstNum=num1;
  printf("Terms present in the Series are:\n");
    for(i=1;i<=n;i++)
  {
     if(i<n)
     {
      printf("%.2f,",seriesFirstNum);
      seriesFirstNum+=diff;
     }
     else
     {
      printf("%.2f\nSum of the Series is=%.2f\n",seriesFirstNum,sum);
      seriesFirstNum+=diff;
     }
  }
}
To find sum of series in A.P for given first and last term of series
Explanation:

//Coming Soon...

Output:
Display Series in AP along with Sum for given Common difference and Number of Terms

Display Series in AP along with Sum for given Common difference and Number of Terms

Display Series in AP along with Sum for given Common difference and Number of Terms


1 comment:

  1. factorial hundred In the last few days, the “factorial of 100” is one of the top subjects and a lot of maths geeks compute it using voice assistants such as Alexa, Shiri, etc.

    factorial hundred In the last few days, the “factorial of 100” is one of the top subjects and a lot of maths geeks compute it using voice assistants such as Alexa, Shiri, etc.

    factorial hundred In the last few days, the “factorial of 100” is one of the top subjects and a lot of maths geeks compute it using voice assistants such as Alexa, Shiri, etc.

    vegamovies Earlier people were not so much means to watch movies and to watch movies, we had to go to the movies hall where we were not allowed to go without tickets, but now people can watch movies online since the internet became cheaper.

    ReplyDelete

Donate

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide