Advertisement
luizaspan

[Revisão] Modelo função C

Aug 21st, 2015
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. #define n 160
  5.  
  6. double fatorial(int n) // n=j durante a andamento da função
  7. {
  8.     double fat = 1.0;
  9.     int i;
  10.  
  11.     for (i=1;i<=n;i++)
  12.         fat=fat*i;
  13.  
  14.     return fat;
  15. }
  16.  
  17. main()
  18. {
  19.     int i,j;
  20.     double fat;
  21.  
  22.     for (j=1;j<=n;j++)
  23.     {
  24.         fat=fatorial(j);
  25.         printf("%d %15.e \n",j,fat); // em vez de fat, poderia ser fatorial(j) e não atribuir à variável fat o valor de fatorial(j).
  26.     }
  27.  
  28.    
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement