Puzzle L13


Print integers from 1 to 100 that are not multiples of 3 or 5

[E-8]Write a main() program that prints the integers from 1 up to 100 that are not multiples of 3 or 5. Print ten integers per line. The output of the program is:

  1  2  4  7  8 11 13 14 16 17
 19 22 23 26 28 29 31 32 34 37
 38 41 43 44 46 47 49 52 53 56
 58 59 61 62 64 67 68 71 73 74
 76 77 79 82 83 86 88 89 91 92
 94 97 98

Here is a skeleton:

#include <stdio.h>
#include <stdlib.h>

/* Puzzle L13 -- print integers from 1 to n that are not multiples of 3 or 5
|  Print 10 integers per line.
|  End the last line with "\n", even if the line has fewer than
|  ten numbers on it.
|
*/
int main()
{
  int j;
  int count = 0;
  int n = 100;
  
  /* Generate Integers */
  for (  )
  {
    /* Test if the integer should be printed */
    if (   )
    {
      printf("%3d", j);

    }
  }

  /* Last Line Logic */
  if (   ) printf("\n");
  
  return 0;
}



Answer         Next Page         Previous Page Home