// july3ex2.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

int main(int argc, char* argv[])
{
int maxvalue, kount, kount23;

/*This program examines all of the numbers 1 through N and prints one
of the following messages next to the number:

	 *  Divisible by 2
	 *  Divisible by 3
	 *  Divisible by both 2 and 3
	 *  Not divisible by 2 nor 3
	 
	   This version introduces the AND boolean operator - &&

        It also counts the number of times that a generated number is div by BOTH 2 and 3
	*/
	
   printf("Type in the max value: ");
   scanf ("%d", &maxvalue); 	
   printf ("Your max value is %d\n", maxvalue);

   kount23 = 0;
   kount = 1;
   while (kount <= maxvalue) {

	   printf("%d ", kount);

	   if (  (kount % 2 ==0)  && (kount % 3 ==0)  ) {
		       kount23 = kount23 + 1;
			   printf ("is divisible by both 2 and 3! \n");
	   }  /* end if (kount % 2 ==0)  && (kount % 3 ==0) */


	   if (  (kount % 2 ==0)  && (kount % 3 !=0)  )
				printf (" is divisible by 2 only. \n");

	   if (  (kount % 2 !=0)  && (kount % 3 ==0)  )
			   printf ("is divisible by 3 only. \n");
	

	   if (  (kount % 2 !=0)  && (kount % 3 !=0)  )
				printf ("is not divisible by 2 or 3. \n");

	   kount = kount +1;


   } /*end of while kount */

   printf("\nThe count of numbers div by both 2 and 3 = %d\n", kount23);

	return 0;
}