luizaspan icon

[Revisão] Modelo função C

luizaspan | PRO | 08/21/15 07:30:47 PM UTC | 0 ⭐ | 748 👁️ | Never ⏰ | []
C |

430 B

|

None

|

0 👍

/

0 👎

#include <stdio.h>
#include <math.h>
 
#define n 160
 
double fatorial(int n) // n=j durante a andamento da função
{
    double fat = 1.0;
    int i;
 
    for (i=1;i<=n;i++)
        fat=fat*i;
 
    return fat;
}
 
main()
{
    int i,j;
    double fat;
 
    for (j=1;j<=n;j++)
    {
        fat=fatorial(j);
        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).
    }
 
    
}

Comments