elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


  Mostrar Mensajes
Páginas: [1]
1  Programación / Programación C/C++ / Re: en: 20 Febrero 2017, 23:16 pm
Hola... No intente compilar tu código pero algo así debería de funcionar
Código
  1. #include<stdio.h>
  2. float exp(float x, float y){
  3.    if (y>1){
  4.        return x*exp(x,y-1);
  5.    }
  6.    else{
  7.        return x;
  8.    }
  9. }
  10. float fact(float x){
  11.    if (x>2){
  12.        return x*fact(x-1);
  13.    }
  14.    else{
  15.        return x;
  16.    }
  17. }
  18. void main(){
  19.    int opt;
  20.    float x,y;
  21.    printf("Seleccione un numero\n");
  22.    printf("1) Exponente\n");
  23.    printf("2) Factorial\n");
  24.    printf("3) Seno\n");
  25.    scanf("%d",&opt);
  26.    switch(opt){
  27.        case 1:
  28.        printf("ingrese la base\n");
  29.        scanf("%f",&x);
  30.        printf("ingrese el exponente\n");
  31.        scanf("%f",&y);
  32.        printf("El resultado es: %2f",exp(x,y));
  33.        break;
  34.        case 2:
  35.        printf("Ingrese un numero\n");
  36.        scanf("%f",&x);
  37.        printf("El resultado es: %2f",fact(x));
  38.        break;
  39.        case 3:
  40.        printf("Ingrese el lado opuesto\n");
  41.        scanf("%f",&x);
  42.        printf("Ingrese la hipotenusa\n");
  43.        scanf("%f",&y);
  44.        printf("El resultado es: %2f",x/y);
  45.        break;
  46.    }
  47. }


Enviado desde mi LG-H542 mediante Tapatalk
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines