viernes, 16 de noviembre de 2018

FUNCION MATEMATICA


PROGRMA PARA RESOLVER OPERCIONES MATEMATICAS BASICA


#include <stdio.h>
#include <math.h>

int main ()
{
                float div;
               
                printf("\n ELIJA OPCION");
                printf("\n 1 - +");
                printf("\n 2 - -");
                printf("\n 3 - *");
                int n1, n2, su, res, mult, op;

                printf("\n 4 - /");
               
                printf("\n INGRESE SU OPCION: ");
                scanf("%d", &op);
               
                if (op==1)
                {
                               printf ("\n SUMA");
                               printf ("\n INGRESE PRIMER NUMERO: ");
                               scanf ("%d", & n1);
                               printf ("\n INGRESE SEGUNDO NUMERO: ");
                               scanf ("%d", &n2);
                               su=n1+n2;
                    printf ("\n LA SUMA ES:%d", su);
                }
               
                               if (op==2)
                {
                               printf ("\n RESTA");
                               printf ("\n INGRESE PRIMER NUMERO: ");
                               scanf ("%d", & n1);
                               printf ("\n INGRESE SEGUNDO NUMERO: ");
                               scanf ("%d", &n2);
                               res=n1-n2;
                    printf ("\n LA RESTA ES:%d", res);
                }
               
                if (op==3)
                {
                               printf ("\n MULTIPLICACION");
                               printf ("\n INGRESE PRIMER NUMERO: ");
                               scanf ("%d", & n1);
                               printf ("\n INGRESE SEGUNDO NUMERO: ");
                               scanf ("%d", &n2);
                               mult=n1*n2;
                    printf ("\n LA MULTIPLICACION ES:%d", mult);
                }
                if (op==4)
                {
                               printf ("\n DIVISION");
                               printf ("\n INGRESE PRIMER NUMERO: ");
                               scanf ("%d", & n1);
                               printf ("\n INGRESE SEGUNDO NUMERO: ");
                               scanf ("%d", &n2);
                               div=n1/n2;
                    printf ("\n LA DIVISION ES:%2.f", div);
                }
               
}

No hay comentarios.:

Publicar un comentario