Preview:
#include <stdio.h>
#include <string.h>

struct Product
{
    char name [20];
    char brand [20];
    float price ;
    int quantity;

};

void print_product(struct Product a_product);

int main(void)
{
    struct Product a_product[3];
    
    sprintf(a_product[0].name,"Xbox One S");
    sprintf(a_product[0].brand,"Microsoft");
    a_product[0].price= 395.50;
    a_product[0].quantity = 35;
    
    sprintf(a_product[1].name,"PlayStation 4 Pro");
    sprintf(a_product[1].brand,"Sony");
    a_product[1].price= 538.00;
    a_product[1].quantity = 71;
    
    sprintf(a_product[2].name,"Switch");
    sprintf(a_product[2].brand,"Nintendo");
    a_product[2].price= 529.95;
    a_product[2].quantity = 8;
    
    for(int i = 0; i < 3; i++)
    {
        print_product(a_product[i]);
    }
	return 0;
}

void print_product(struct Product a_product)
{
	printf("Item name: %s\n", a_product.name);
	printf("Brand:     %s\n", a_product.brand);
	printf("Price:     $%.2f\n", a_product.price);
	printf("Quantity:  %d\n\n", a_product.quantity);
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter