struct invent
{
char *name[20];
int number;
float price;
};
main()
{
struct invent product[3], *ptr;
printf("INPUT\n\n");
for(ptr = product; ptr < product+3; ptr++)
scanf("%s %d %f", ptr->name, &ptr->number, &ptr->price);
printf("\nOUTPUT\n\n");
ptr = product;
while(ptr < product + 3)
{
printf("%-20s %5d %10.2f\n",
ptr->name,
ptr->number,
ptr->price);
ptr++;
}
}
Output
INPUT
Washing_machine 5 7500
Electric_iron 12 350
Two_in_one 7 1250
OUTPUT
Washing machine 5 7500.00
Electric_iron 12 350.00
Two_in_one 7 1250.00