Mostrando entradas con la etiqueta Funciones. Mostrar todas las entradas
Mostrando entradas con la etiqueta Funciones. Mostrar todas las entradas

martes, 13 de diciembre de 2016

Mutiplicacion y division

#include<stdio.h>
#include<conio.h>
#include<math.h>
float funA(float x,float y,float z);
void FunB(void);
int main()
{
    FunB();
    getch();
}
 void FunB(void)
 {
      float x,y,z;
      printf("Introduce el valor de x\n");
      scanf("%f",&x);
      printf("Introduce el valor de y\n");
      scanf("%f",&y);
      printf("Introduce el valor de z\n");
      scanf("%f",&z);
      printf("El valor de la funcion A=%.2f con valores de x=%.2f, y=%.2f, z=%.2f",funA(x,y,z),x,y,z);
 }  
 float funA(float x,float y,float z)
 {
       float op=(x*y)/z;
       return op;
 }
     

Funciones que no reciben y no retornan VALOR DE UN PUNTO

/*Funciones que no reciben y no retornan*/
#include<stdio.h>
#include<conio.h>
void funB(void);
int main()
{
funB();
getch();

}
void funB(void)
{
float x,y,z,funB;
printf("Introduce el valor de x...\n");
scanf("%f",&x);
printf("Introduce el valor de y...\n");
scanf("%f",&y);
printf("Introduce el valor de z...\n");
scanf("%f",&z);
funB=(x*y)/z;
printf("El valor de la funcion B=%.2f, con valores de x=%f, y=%f, z=%f",funB,x,y,z);

}

Funcion que no recibe ni retorna CONVERSIONES

/*Funcion que no recibe ni retorna*/
#include<stdio.h>
#include<math.h>
#include<conio.h>
void conversiones (void);
void conv_cm_a_in(float cm);
void conv_cm_a_m(float cm);
void conv_cm_a_ft(float cm);
void conv_cm_a_yarda(float cm);
void conv_cm_a_milla(float cm);
int main()
{
    conversiones();
    getch();
}
void conversiones(void)
{
     float cm;
     printf("Introduce los cm a convertir...\n");
     scanf("%f",&cm);
     conv_cm_a_in(cm);
     conv_cm_a_m(cm);
     conv_cm_a_ft(cm);
     conv_cm_a_yarda(cm);
     conv_cm_a_milla(cm);
   
}
void conv_cm_a_in(float cm)
{
     float in;
   
     in=(cm*0.393701);
     printf("conversion de cm a in=%.2f pulgadas \n",in);
}
void conv_cm_a_m(float cm)
{
     float m;
   
     m=(cm/100);
     printf("conversion de cm a m=%.2f metros \n",m);
}
void conv_cm_a_ft(float cm)
{
     float ft;
   
     ft=(cm*0.0328084);
     printf("conversion de cm a ft=%.2f pies \n",ft);
}
void conv_cm_a_yarda(float cm)
{
     float yarda;
 
     yarda=(cm*0.0109361);
     printf("conversion de cm a yardas=%.2f \n",yarda);
}
void conv_cm_a_milla(float cm)
{
     float milla;
   
     milla=(cm*(6.21371*pow(10,-6)));
     printf("conversion de cm a millas=%f \n",milla);
}

Funcion que recibe y retorna retorna POBLACION

/*Funcion que recibe y retorna*/
#include<stdio.h>
#include<math.h>
#include<conio.h>

float poblacion(float x);

int main()
{
    float x,result;
    printf("Introducir el año a estimar la poblacion...\n");
    scanf("%f",&x);
    result=poblacion(x);
    printf("En el año=%f, la poblacion estimada sera de=%f miles de millones\n",x,result);
    getch();
    }
    float poblacion(float x)
    {
          float result;
          result=((6.0)*exp(0.02*(x-2000)));
          return result;
}
       
 

Funciones que reciben y no retornan

/*Funciones que reciben y no retornan*/
#include<stdio.h>
#include<math.h>
#include<conio.h>
void FGen1(float a, float b, float c);
void FGen2(float a, float b, float c);
int main()
{
    float a, b, c, x1, x2;
    printf("Introduce los valores (a,b,c)...\n");
    scanf("%f,%f,%f",&a,&b,&c);
    FGen1(a,b,c);
    FGen2(a,b,c);
    getch();
}
void FGen1(float a, float b, float c)
{
      float x1;
      x1=(-b+sqrt(pow(b,2)-(4*a*c)))/(2*a);
      printf("FGen1=%f\n",x1);
}
void FGen2(float a, float b, float c)
{
      float x2;
      x2=(-b-sqrt(pow(b,2)-(4*a*c)))/(2*a);
      printf("FGen2=%f\n",x2);
     
}

Funciones que reciben y no retornan FORMULA GENERAL

/*Funciones que reciben y no retornan*/
#include<stdio.h>
#include<math.h>
#include<conio.h>
void FGen1(float a, float b, float c);
void FGen2(float a, float b, float c);
int main()
{
    float a, b, c, x1, x2;
    printf("Introduce los valores (a,b,c)...\n");
    scanf("%f,%f,%f",&a,&b,&c);
    FGen1(a,b,c);
    FGen2(a,b,c);
    getch();
}
void FGen1(float a, float b, float c)
{
      float x1;
      x1=(-b+sqrt(pow(b,2)-(4*a*c)))/(2*a);
      printf("FGen1=%f\n",x1);
}
void FGen2(float a, float b, float c)
{
      float x2;
      x2=(-b-sqrt(pow(b,2)-(4*a*c)))/(2*a);
      printf("FGen2=%f\n",x2);
     
}

Funciones que no reciben y no retornan DISTANCIA

/*funciones que no reciben y no retornan*/
#include<stdio.h>
#include<math.h>
#include<conio.h>
void distancia(void);
int main()
{
distancia();
getch();
}
void distancia(void)
{
float x1,y1,x2,y2,d1;
printf("Introduce los valores de(P)...\n");
scanf("%f,%f",&x1,&y1);
printf("Introduce los valores de(Q)...\n");
scanf("%f,%f",&x2,&y2);
d1=sqrt(pow(x2-x1,2)+pow(y2-y1,2));
printf("distancia=%f\n",d1);
}

Funciones que no reciben y retornan DISTANCIA

/*Funciones que no reciben y retornan*/
#include<stdio.h>
#include<math.h>
#include<conio.h>
float distancia(void);
int main()
{
float d1;
d1=distancia();
printf("distancia=%f \n",d1);
getch();
}
float distancia(void)
{
float x1,y1,x2,y2,d1;
printf("Introduce valores de(P)...\n");
scanf("%f,%f",&x1,&y1);
printf("Introduce valores de(Q)...\n");
scanf("%f,%f",&x2,&y2);

d1=sqrt(pow(x2-x1,2)+pow(y2-y1,2));
return d1;
}

Funciones que no reciben y no retornan FORMULA GENERAL

/*funciones que no reciben y no retornan*/
#include<stdio.h>
#include<math.h>
#include<conio.h>
void FGen1(void);
int main()
{
FGen1();
getch();

}
void FGen1(void)
{
float a, b, c, x1,x2;
printf("Introduce los valores (a,b,c)...\n");
scanf("%f,%f,%f",&a, &b, &c);
x1=(-b+sqrt(pow(b,2)-(4*a*c)))/(2*a);
printf("FGen1=%f \n", x1);
x2=(-b-sqrt(pow(b,2)-(4*a*c)))/(2*a);
printf("FGen2=%f \n", x2);
}

Funciones que no reciben y no retornan

/*funciones que no reciben y no retornan*/
#include<stdio.h>
#include<math.h>
#include<conio.h>
void FGen1(void);
int main()
{
FGen1();
getch();

}
void FGen1(void)
{
float a, b, c, x1,x2;
printf("Introduce los valores (a,b,c)...\n");
scanf("%f,%f,%f",&a, &b, &c);
x1=(-b+sqrt(pow(b,2)-(4*a*c)))/(2*a);
printf("FGen1=%f \n", x1);
x2=(-b-sqrt(pow(b,2)-(4*a*c)))/(2*a);
printf("FGen2=%f \n", x2);
}

Funciones que no reciben y retornan

/*Funciones que no reciben y retornan*/
#include<stdio.h>
#include<math.h>
#include<conio.h>
float FGen1(void);
float FGen2(void);
int main()
{
    float x1,y2;
   
    x1=FGen1();
    y2=FGen2();
    printf("FGen1=%f \n",x1);
    printf("FGen2=%f \n",y2);
     getch();
}
float FGen1(void)
{
      float a,b,c,x1;
      printf("Introduce valores (a,b,c)...\n");
      scanf("%f,%f,%f",&a, &b, &c);
      x1=(-b+sqrt(pow(b,2)-(4*a*c)))/(2*a);
      return x1;
     
}
float FGen2(void)
{
      float a,b,c,x2;
      x2=(-b-sqrt(pow(b,2)-(4*a*c)))/(2*a);
      return x2;
}

Funciones que reciben y no retornan DISTANCIA

/*Funciones que reciben y no retornan*/
#include<stdio.h>
#include<math.h>
#include<conio.h>
void distancia(float x1, float y1, float x2, float y2);
int main()
{
    float x1, y1, x2, y2,result;
    printf("Introduce los valores de (P)...\n");
    scanf("%f,%f",&x1,&y1);
     printf("Introduce los valores de (Q)...\n");
    scanf("%f,%f",&x2,&y2);
    distancia(x1,y1,x2,y2);
    getch();
}
void distancia(float x1, float y1, float x2, float y2)
{
      float result;
      result=sqrt(pow(x2-x1,2)+pow(y2-y1,2));
      printf("d1=%f\n",result);
}

Funciones que reciben y retornan

/*Funciones que reciben y retornan*/
#include<stdio.h>
#include<math.h>
#include<conio.h>
float FGen1(float a, float b, float c);
float FGen2(float a, float b, float c);
int main()
{
    float a, b, c, x1, x2;
    printf("Introduce los valores (a,b,c)...\n");
    scanf("%f,%f,%f",&a,&b,&c);
    x1=FGen1(a,b,c);
    x2=FGen2(a,b,c);
    printf("FGen=%f\n",x1);
    printf("FGen=%f\n",x2);
    getch();
}
float FGen1(float a, float b, float c)
{
      float x1;
      x1=(-b+sqrt(pow(b,2)-(4*a*c)))/(2*a);
      return x1;
}
float FGen2(float a, float b, float c)
{
      float x2;
      x2=(-b-sqrt(pow(b,2)-(4*a*c)))/(2*a);
      return x2;
}

Funciones que reciben y retornan DISTANCIA

/*Funciones que reciben y retornan*/
#include<stdio.h>
#include<math.h>
#include<conio.h>
float distancia(float x1, float y1, float x2, float y2);
int main()
{
float x1,y1,x2,y2,result;
    printf("Introduce los valores de(P)...\n");
scanf("%f,%f",&x1,&y1);
printf("Introduce los valores de(Q)...\n");
scanf("%f,%f",&x2,&y2);
result=distancia(x1,y1,x2,y2);
printf("distancia=%f\n",result);
getch();
}
float distancia(float x1, float y1, float x2, float y2)
{
float result;
result=sqrt(pow((x2-x1),2)+pow((y2-y1),2));
return result;
}

Apunte 6/09/2016

6/SEPTIEMBRE/2016 APUNTE

Programación estructurada
Es un tipo de programación que hace uso de estructuras secuenciales, condicionales y repetitivas.
Nos permite resolver un problema dividiendo en n partes, cada parte es una subrutina o también llamada función.