Jump to content
Fórum Script Brasil
  • 0

funções em c


methoB_man

Question

monte um algoritmo que calcule:

H=1!/1 + 3!/3 + 5!/5 separando em funções

tentei fazer assim , mas não sei por que não deu certo

#include <stdio.h>
#include <conio.h>

int fat(int);
int num (int);

int fat(int n)
{
    int i=0;
    int p=0;
    int fat=1;
do
{
    p++;
    fat=fat*p;
    if (p%2!=0)
    {
         return fat;
         i++;
    }    
}
while (i<n);
}

int num(int n)
{
    int c=-1;
    int i=1;
    for (i=1;i<=n;i++)
   {
      c=c+2;
      return c;
   }
}

main()
{
      int i;
      int n;
      float soma=0;

printf("quantidade de termos da sequência\n");
scanf("%d",&n);

for(i=1;i<=n;i++)
   {
     soma=soma+fat(n)/num(n);
     printf("%f\n",soma);
   }
    getch();
}

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652.1k
×
×
  • Create New...