21 lines
484 B
C
21 lines
484 B
C
/*
|
|
*Student: S.K Soekhlal
|
|
* Number: 4860632
|
|
* Assignment: 1.4
|
|
*/
|
|
|
|
#include<stdio.h>
|
|
#include<stdlib.h>
|
|
#include<math.h>
|
|
|
|
int main(){
|
|
double a,r,b=0,sum=0; /*Declaring variables*/
|
|
int N;
|
|
scanf("%lf%d%lf",&a,&N,&r); /*Storing inputted values in variables*/
|
|
for(;N>=0;--N){ /*Starting for loop to calculate sum*/
|
|
b = a * (pow(r,N)); /*calculating sum*/
|
|
sum += b;
|
|
}
|
|
printf("%.2f\n", sum); /*Printing sum on the screen*/
|
|
return 0;
|
|
} |