Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define num 5
- struct Productos{
- float precio;
- char nombre[20];
- char marca[20];
- };
- int main(int argc, char *argv[])
- {
- struct Productos *prod;
- prod=(struct Productos*)malloc(sizeof(struct Productos)*num);
- int i;
- strcpy(prod[0].marca, "Apple");
- strcpy(prod[0].nombre, "IPhone 4g");
- prod[0].precio=9500.50f;
- strcpy(prod[1].marca, "Sony");
- strcpy(prod[1].nombre, "Playstation 3");
- prod[1].precio=9350.86f;
- strcpy(prod[2].marca, "Acer");
- strcpy(prod[2].nombre, "Acer Aspire 4225");
- prod[2].precio=7400.43f;
- strcpy(prod[3].marca, "Apple");
- strcpy(prod[3].nombre, "IPod Touch 4g");
- prod[3].precio=4600.50f;
- strcpy(prod[4].marca, "Sony Ericcson");
- strcpy(prod[4].nombre, "Xperia Pro");
- prod[4].precio=5300.87f;
- printf("Nombre_Producto\t\tMarca\t\t\t\tPrecio\n\n\n");
- for(i=0;i<num;i++)
- printf("%-20s\t%-20s\t\t%-20.2f\n\n", prod[i].nombre, prod[i].marca, prod[i].precio);
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment