Que pida 5 productos
5% de desc
despliegue por pantalla
nombre del articulo
precio del articulo
cantidad del articulo comprado
iva
y el precio total
si le pueden poner color verde al codigo lo necesito por favor ayudenme es para mañana!!
Copyright © 2024 Q2A.MX - All rights reserved.
Answers & Comments
Verified answer
Hola, ¿cómo estás?
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
typedef struct Producto Producto;
struct Producto {
char nombre[50];
float precio;
unsigned int cantidad;
float iva;
};
int main(void) {
system("color A");
unsigned short i;
Producto productos[5];
float precioTotal = 0.0;
float subTotal = 0.0;
float iva = 0.0;
for (i = 0; i < 5; ++i) {
strcat(productos[i].nombre, "Sin nombre");
productos[i].precio = 0.0;
productos[i].cantidad = 0;
productos[i].iva = 0.0;
printf("Nombre?: ");
fflush(stdin);
gets(productos[i].nombre);
printf("Precio?: ");
fflush(stdin);
scanf("%f", &productos[i].precio);
printf("Cantidad?: ");
fflush(stdin);
scanf("%u", &productos[i].cantidad);
productos[i].iva = productos[i].precio * 0.16;
iva += productos[i].iva;
subTotal += productos[i].precio;
precioTotal += iva + subTotal;
}
printf("Subtotal: %f\n", subTotal);
printf("IVA: %f\n", iva);
printf("Total: %f\n\n", precioTotal);
puts("Presione una tecla para terminar");
getch();
return 0;
}
Saludos.