Good night, I wonder, why my code returns a wrong value for a case where the input is 1.1 and 100000, the output should give 100000 and 5000050000 and this is giving 100000 and 705082704 ?? the output should be double or float ??
#include <stdio.h> //Bibliteca para as fuñcoes de entrada e saida
int main (void) //Programa principal
{
int a1, r, n, An, Sn; //Declaracao das variaveis necessarias
scanf("%d\n%d\n%d",&a1, &r, &n); //Insercao dos valores de A1, r e n
An = a1+(n-1)*r; //Formula para encontrar o enesimo termo da PA
printf("%d\n", An); //Impressao na tela do valor do enesimo termo encontrado
Sn = (a1+An)*n/2; //Formula para fazer a soma dos "n" termos da PA
printf("%d", Sn); //Impressao na tela do valor da soma da PA
return 0;
}