20 lines
503 B
C
20 lines
503 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int main () {
|
|
float a1, d; /* Initial Term and Difference */
|
|
int n; /* Number of Element */
|
|
|
|
printf("Enter the initial term (a1): ");
|
|
scanf("%f", &a1);
|
|
|
|
printf("Please enter the difference in the arithmetic sequence: ");
|
|
scanf("%f", &d);
|
|
|
|
printf("Please enter the number of elements the arithmetic sequence: ");
|
|
scanf("%d", &n);
|
|
|
|
printf("The sum of the terms is in the arithmetic sequence is %.2f\n", ((a1 + (a1 + (n - 1) * d)) / 2) * n);
|
|
|
|
return 0;
|
|
}
|