C++ SUM - I can not finish it...
Hello, can somebody help me?
I need 20(summ)k=0 for 0.1(pow k) / k!
in: DEV CPP for faktorial I have:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
float k, fakt;
printf("Number k: ");
scanf("%f", &k);
fakt = 1;
while (k >= 1 ){
fakt = fakt * k;
k = k - 1;
}
printf("Faktorial: %f \n", fakt);
system("pause");
return(0);
}
|
But the problem is with number 20... If I write k = 20 I will get bad factorial...
For top 0.1(pow k) I have...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
float a, k, i, end;
printf("Number k: ");
scanf("%f", &k);
a = 0.1;
while (k >= 1 ){
end = 1*pow(a, k);
printf("Number %.0f: %f \n", k, end);
k = k - 1;
}
system("pause");
return(0);
}
|
This is clear...
But how Can I do all of numbers behind decimal point? Not 0.00000...
Now I need 0.1(pow k) / k!
and make a Sum for 20(summ)k=0 for 0.1(pow k) / k! ... 20 is mean as k
Here I am lost... Thank you for solution guys :-)
Last edited on
Topic archived. No new replies allowed.