In: Computer Science
How many integers from 1 to 500 inclusive are
(a) divisible by 6, but are divisible by neither 8 nor 10?
(b) divisible by 6 or 8, but are not divisible by 10?
(c) divisible by 6 and 8, or are not divisible by 10?
integers from 1 to 500 inclusive are
(a) divisible by 6, but are divisible by neither 8 nor 10 -----> 51
(b) divisible by 6 or 8, but are not divisible by 10------------->117
(c) divisible by 6 and 8, or are not divisible by 10------------->454
for this try this program main.c----->
#include <stdio.h>
void main()
{
int i, count1 = 0, count2 = 0, count3 = 0;
for (i = 1; i <= 500; i++)
{
if (i % 6 == 0
&& i%8!=0 && i%10!=0)
{
count1++;
}
if (i % 6 == 0 || i%8==0 && i%10!=0)
{
count2++;
}
if (i % 6 == 0 && i%8==0 || i%10!=0)
{
count3++;
}
}
printf("%d\n%d\n%d",count1,count2,count3);
}