Consider the following structure definition struct item char

Consider the following structure definition: struct item {char part_no[8]; char desc[20]; float price; int int_stock;}; Assign a price 15.75 to the 33^rd item\'s? Assign the second character of the 12^th item\'s part number the value \'y\'? Assign the 97^th inventory item the same value as the 63^rd? What is wrong with each of the following statements? item[1].price = 92.32; strepy(inventory.desc, \"Widgets\"); inventory.price[10] = 32.12; Consider the following structure declaration: struct Item {int invenNum; double cost; int quality;}; Item tool; Which function prototype can be used for a function that displays tool\'s cost? void display(Item tool); void display(double tool.cost); either a or b. neither a nor b The function whose prototype is Item getData(); returns

Solution


struct item{
  
   char part_no[8];
   char desc[20];
   flaot price;
   int int_stock;
}

item inventory[100];

a.
   inventory[32].price = 15.75; // assigining 33rd item\'s price

b.
   inventory[11].part_no[1] = \'y\';

c.
   //assigining part_no
   strcpy(inventory[96].part_no, inventory[62].part_no);
  
   // assigining desc
   strcpy(inventory[96].desc, inventory[62].desc);

   // assigining price
   inventory[96].price = inventory[62].price;
   // assigining stock
   inventory[96].int_stock = inventory[62].int_stock;

d.
   a. item[1].price = 92.32;
       It should be: inventory[1].price = 92.32

   b. strcpy(inventory.desc, \"Widgets\");
       It should be:
           strcpy(inventory[some_index].desc, \"Widgets\");

   c. inventory.price[10] = 32.12

       It should be:
           inventory[10].price = 32.12

 Consider the following structure definition: struct item {char part_no[8]; char desc[20]; float price; int int_stock;}; Assign a price 15.75 to the 33^rd item\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site