S(x,n) = 1 +x + x^2+...+x^n


CHƯƠNG TRÌNH MẪU
Mã:
#include "conio.h"
#include "stdio.h"

float Power(float x, unsigned int n) {
    float temp = 1;
    for(int i = 0; i<n; i++)
        temp*= x;
    return temp;
}
double Sum(float x, unsigned int n) {
    double temp = 0;
    for(int i = 1; i<=n; i++)
        temp+= Power(x,i);
    return temp;
}
void main(){
    clrscr();
    unsigned int n;
    float x;
    printf("Nhap vao n = ");
    scanf("%d",&n);
    printf("Nhap vao x = ");
    scanf("%f",&x);
    printf("S = %.2f",Sum(x,n));
    getch();
}