ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Programa


Enviado por   •  6 de Septiembre de 2015  •  Apuntes  •  577 Palabras (3 Páginas)  •  99 Visitas

Página 1 de 3

PROGRAMA EN C

CALCULADORA USANDO FUNCIONES

#include

#include

#include

void calcu();

void opcion();

void suma(float,float);

void rest(float,float);

void divi(float,float);

void prod(float,float);

void raiz(float,float);

void pote(float,float);

void seno(float, float);

void coseno(float,float);

void main()

{calcu();

}

  void calcu()

  {char op;

   printf("***MENU***");

   printf("\nSUMA(+)\nRESTA(-)\nDIVISION(/)\nPRODUCTO(*)\nRAIZ CUADRADA(r)\nPOTENCIACION(p)\nSENO ANGULO(s)\nCOSENO ANGULO(c)");

   printf("\n\nINTRODUZCA LA OPERACION: ");

   op=getche();

   if((op=='+')||(op=='-')||(op=='/')||(op=='*')||(op=='r')||(op=='p')||(op=='s')||(op=='c'))

   {opcion(op);

   }

   else

   {printf("ERROR");

   }

   return;

  }

   void opcion(op)

  {float a,b=0;

   int e1,e2=0;

   printf("\nINTRODUZCA DOS NUMEROS: ");

   e1=scanf("\n%f",&a);

   e2=scanf("\n%f",&b);

   if((e1==0)||(e2==0))

   {printf("ERROR");

    return;

   }

   else

   if(op=='+')

   {suma(a,b);

   }

   else

   if(op=='-')

   {rest(a,b);

   }

   else

   if(op=='/')

   {divi(a,b);

   }

   else

   if(op=='*')

   {prod(a,b);

   }

   else

   if(op=='r')

   {raiz(a,b);

   }

   else

   if(op=='p')

   {pote(a,b);

   }

   else

    if(op=='s')

   {seno(a,b);

   }

   else

    if(op=='c')

   {coseno(a,b);

   }

 }

     void suma(float x,float y)

     {float R=0;

      R=(x+y);

      printf("\nEL RESULTADO DE LA SUMA ES: %2.2f",R);

      return;

     }

      void rest(float x,float y)

     {float R=0;

      R=(x-y);

      printf("\nEL RESULTADO DE LA RESTA ES: %2.2f",R);

      return;

     }

      void divi(float x,float y)

...

Descargar como (para miembros actualizados)  txt (2.7 Kb)   pdf (32.4 Kb)   docx (12 Kb)  
Leer 2 páginas más »
Disponible sólo en Clubensayos.com