My algorithm needs to sum all values between a
and b
, for example if I type a=3 e b=6
the program needs to speak 3 7 12 18 (3+4= 7/ 7+5=12 / 12+6=18)
only it only makes the first two then it starts to err.
#include <stdio.h>
int main ()
{
int a,b,i,n,x,c;
printf("Digite a: ");
scanf("%d", &a);
printf("Digite b: ");
scanf("%d", &b);
c=0;
for(i=1;i<=b;i++)
{
c=a;
a=c+(a+1);
printf("%d\n ",c);
}
return 0;
}