You are on page 1of 1

#include <stdio.

h>
#include <string.h>
int main(){
const int ITEM_NUM = 5;//the items provide plus one I added

/*All arrays correspond with each other


so the first item and its details will be the 0th element in
all the Arrays and so forth*/
int itemNum[ITEM_NUM]; //Array for all the item Numbers
char description[ITEM_NUM][50]; //Array of Strings for Description
double price[ITEM_NUM]; //Array for the Prices
int count[ITEM_NUM]; //Array for the number of items

//Declared all items together(with their respected array) for clarity


itemNum[0] = 345;
strcpy(description[0], "Bookshelf");
price[0] = 78.51;
count[0] = 4;

itemNum[1] = 7474;
strcpy(description[1], "Pencil");
price[1] = 1.99;
count[1] = 100;

itemNum[2] = 987;
strcpy(description[2], "Chair");
price[2] = 129.99;
count[2] = 6;

itemNum[3] = 2342;
strcpy(description[3], "Computer");
price[3] = 1295.40;
count[3] = 3;

//This is the item I added to list


itemNum[4] = 8923;
strcpy(description[4], "Coffee");
price[4] = 5.49;
count[4] = 5;

printf("Item Num\tDescription\t Price \tCount\t Extended Price\n");


int i = 0;
for(;i < ITEM_NUM; i++){
printf("%06d \t%-11s\t$ %7.2lf\t%5d\t $ %7.2lf\n",itemNum[i],
description[i], price[i], count[i], price[i] * count[i]);
}

return 0;
}

You might also like