Files
C-Bootcamp-Tutorial/A10/2.+Sum+of+Arithmetic+Sequence.c
T
2026-09-24 14:39:54 +02:00

20 lines
454 B
C

//Made by Vlad. Budnitski.
//AlphaTech - Programming Course.
#include <stdio.h>
int main()
{
float a1, an, Sn;
int n;
printf("Enter the Initial Term (a1): ");
scanf("%f", &a1);
printf("Enter the n-th Term (an): ");
scanf("%f", &an);
printf("Enter the number of elements in the Arithmetic Sequence: ");
scanf("%d", &n);
Sn = (a1 + an) * n / 2;
printf("The sum of your sequence = %.2f\n", Sn);
return 0;
}