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

 

 


Tema destacado: Únete al Grupo Steam elhacker.NET


  Mostrar Temas
Páginas: [1]
1  Programación / Programación C/C++ / Programa se cierra al llamar a una funcion dentro de un do-while (lenguaje C) en: 15 Septiembre 2014, 01:47 am
Buenas, tengo un programa que debe leer el nombre de un cliente, los productos que compra, que cantidad, calcular el precio total de compra junto con el impuesto. Todo esto utilizando solo arreglos de una dimension y funciones. El problema es que al llamar la función "ventas" que se encarga de hacer los calculos de impuesto y demás, el programa se cierra sin ningun tipo de error, no se que estoy haciendo mal, ¿podrían echarme una mano por favor?

Les muestro el código que escribí:


Código
  1. #include <stdio.h>
  2. #include <conio.h>
  3. int lectura();
  4. float ventas(int Nombre[30],int Descripcion[30],int Cantidad[30],float Precio[30],int X,int C);
  5. float impresion(int Name[30],int Descr[30],int Cant[30],float Price[30],int X1,int C1,float Precioto[30],float subto,float tax,float Total,float Altotal);
  6. int main()
  7. {
  8. int x=0;
  9. printf("Mi nombre");
  10. for(x=0;x<50;x++)
  11.    {printf("\n");}
  12. lectura();
  13.  
  14. return 0;
  15. }
  16. int lectura()
  17. {
  18. int descripcion[30];
  19. int cantidad[30];
  20. float precio[30];
  21. int nombre[30];
  22. int x=0,c=0;
  23. char lim=0,limprod=0;
  24.   do
  25. {
  26.  printf("\nIngrese el nombre del cliente: ");
  27.  scanf("%s",&nombre[c]);
  28.  do
  29.  {
  30.  printf("\nIngrese descripcion del producto: ");
  31.  scanf("%s",&descripcion[x]);
  32.  printf("\nIngrese cantidad del producto: ");
  33.  scanf("%d",&cantidad[x]);
  34.  printf("\nIngrese precio individual: ");
  35.  scanf("%f",&precio[x]);
  36.  x++;
  37.  printf("\nIngresar otro producto? S/N ");
  38.  limprod=getch();
  39.  }
  40.  while(limprod=='s'||limprod=='S');
  41.  ventas(nombre,descripcion,cantidad,precio,x,c);
  42.  printf("\nProcesar otro cliente? S/N");
  43.  lim=getch();
  44.  c++;
  45. }
  46. while(lim=='s'||lim=='S');
  47. }
  48. float ventas(int Nombre[30],int Descripcion[30],int Cantidad[30],float Precio[30],int X,int C)
  49. {
  50.    float precioto[30];
  51.    int n=0;
  52.    float subtotal=0,impuesto=0,total=0,altotal=0;
  53.    int cltotal=0;
  54.    for(n=0;n<X;n++)
  55.    {
  56.     precioto[n]=Cantidad[n]*Precio[n];
  57.     subtotal+=precioto[n];
  58.    }
  59.    impuesto=subtotal*0.07;
  60.    total=subtotal+impuesto;
  61.    altotal+=total;
  62.    impresion(Nombre,Descripcion,Cantidad,Precio,X,C,precioto,subtotal,impuesto,total,altotal);
  63. }
  64. float impresion(int Name[30],int Descr[30],int Cant[30],float Price[30],int X1,int C1,float Precioto[30],float subto,float tax,float Total,float Altotal)
  65. {
  66.    int n=0;
  67.    printf("\n");
  68.    printf(" Nombre del cliente: x %s x",Name[C1]);
  69.    printf("\nDESCRIPCION\tCANTIDAD\tPRECIO\tPRECIO TOTAL");
  70.    for(n=0;n<X1;n++)
  71.    {
  72.     printf("\n%s\t%.2f\t%.2f\t%.2f",Descr[n],Cant[n],Price[n],Total);
  73.    }
  74.    printf("\n\t\tSUBTOTAL: %.2f",Precioto);
  75.    printf("\n\t\tITBMS: %.2f",tax);
  76.    printf("\n\t\tTOTAL A PAGAR: %.2f",Total);
  77.    printf("\n");
  78.    printf(" Nombre del cliente: x %s x",Name[C1]);
  79.    printf("\nDescripcion\tCANTIDAD\tPRECIO\tPRECIO TOTAL");
  80.    printf("\nTotal Vendido por el Almacen: %.2f",Altotal);
  81. }
  82.  
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines