Puzzle T8


Apply a function to each element of an array

array of five bulbs

Write a main() that declares and initializes an array of Bulbs. Apply the lumen diminishing function (puzzle 07) to each Bulb of the array. Print out the array.

#include <stdio.h>

struct Bulb
{
  int watts;
  int lumens;
};

/* function to print a Bulb */
void printBulb()
{
}

void dimBulb( struct Bulb *b )
{
}

int main()
{
  /* declare and initialize a Bulb array */
  #define length 5
  struct Bulb lights[length] = { {100,1710}, {60,1065}, {100,1530}, {40,505}, {75,830} };

  /* print the Bulbs */

  /* decrease light output of each Bulb */

  /* print the Bulbs */
  

  return 0;
} 


Previous Page        Answer         Next Page         Home