Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #pragma hdrstop
- #include<stdio.h>
- #include<conio.h>
- #include<math.h>
- //---------------------------------------------------------------------------
- double puissance(double a,int b);
- int factorielle(int n);
- double exponentielle(int exp);
- double sinus(double x);
- double logarithme(double log);
- //---------------------------------------------------------------------------
- double puissance (double a,int b)
- {
- double c;
- for (c=1;b>=1;b--)
- {
- c = c * a ;
- }
- return c;
- }
- //---------------------------------------------------------------------------
- int factorielle(int n)
- {
- int i; /*compteur de boucle*/
- for(i=n-1 ; i>=1 ;i--)
- {
- n=n*i;
- }
- return n;
- }
- //---------------------------------------------------------------------------
- double exponentielle(int exp)
- {
- int y;
- double a = 0;
- for(y=1;y<=11;y++)
- {
- a = a + (puissance(exp,y)/(double)factorielle(y) );
- }
- return 1 + a;
- }
- //---------------------------------------------------------------------------
- double sinus(double s)
- {
- int v;
- double b = 0;
- int signe = -1;
- for(v=3;v<=11;v=v+2)
- {
- b = b - (puissance(s,v)/(double)factorielle(v) * signe);
- signe = signe * (-1);
- }
- return s - b;
- }
- //---------------------------------------------------------------------------
- double logarithme(double log)
- {
- int c;
- double z = (log-1)/(log+1);
- double a = 0;
- for(c=1;c<=11;c =c+2)
- {
- a = a + (puissance(z,c))/c;
- }
- return 2 * a;
- }
- //---------------------------------------------------------------------------
- void main()/*Programme Principal*/
- {
- int a,b,n,reponse;
- double y,resultat,x,rep,q,res,w,calc;
- char choix;
- printf("Entrer 1 pour la fonction puissance\n");
- printf("Entrer 2 pour la fonction factorielle\n");
- printf("Entrer 3 pour la fonction exponentielle\n");
- printf("Entrer 4 pour la fonction sinus\n");
- printf("Entrer 5 pour la fonction logarythme\n");
- scanf("%c",&choix);
- flushall();
- switch(choix)
- {
- case'1':/*Fonction Puissance*/
- printf("Entrer un nombre:\n");
- scanf("%lf",&y);
- printf("Entrer sa puissance:\n");
- scanf("%d",&b);
- resultat = puissance(y,b);
- printf("Voici son resultat:%lf\n",resultat);
- break;
- case'2':/*Fonction Factorielle*/
- printf("Entrer un nombre:\n");
- scanf("%d",&n);
- reponse = factorielle(n);
- printf("Voici son resultat:%d\n",reponse);
- break;
- case'3':/*Fonction Exponentielle*/
- printf("Entrer un nombre:\n");
- scanf("%lf",&x);
- rep = exponentielle(x);
- printf("Voici son resultat:%lf\n",rep);
- break;
- case'4':/*Fonction Sinus*/
- printf("Entrer un nombre:\n");
- scanf("%lf",&q);
- res = sinus(q);
- printf("Voici son resultat:%lf\n",res);
- break;
- case'5':/*Fonction Logarithme Népérien*/
- printf("Entrer un nombre:\n");
- scanf("%lf",&w);
- calc = logarithme(w);
- printf("Voici son resultat:%lf\n",calc);
- break;
- }
- getch();
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement