Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //IFF - Programação Estruturada
- //Lista de Exercícios 0 - Exercício 6
- #include<stdio.h>
- #include<math.h>
- float calcularS(int a, int n){
- float s=0;
- for(int x=1;x<=n;x++){
- s+=x/pow(a,x);
- }
- return s;
- }
- int main(){
- setbuf(stdout,NULL);
- int a=0, n=0;
- printf("Entre com o valor de a: ");
- scanf("%d",&a);
- do{
- printf("Entre com o valor de n, sendo n maior ou igual a 1: ");
- scanf("%d",&n);
- }while(n<1);
- printf("S=%.3f",calcularS(a,n));
- }
Advertisement
Add Comment
Please, Sign In to add comment