100 719
Assignments Done
97.9%
Successfully Done
In July 2021

# Answer to Question #4302 in AJAX | JavaScript | HTML | PHP for Johann

Question #4302
Print out all numbers between 0 & 1000 which are evenly divisible by three OR seven. Print them on different lines.Print out all numbers between 0 & 1000 which are evenly divisible by three OR seven. Print them on different lines.

7) Write a loop which prints out every third number between 11 & 21 inclusive.

8) Write a loop which calculates 5 factorial.

9) Write a loop which calculates the average of all of the numbers which are evenly divisible by 3 and lie between 70 & 101 inclusive. The average should be a double.

10) Write a loop which sums up 1/20 + 1/19 + 1/18 +...1/2.
1
2011-10-07T08:21:05-0400
#include <stdio.h>

//~ Print out all numbers between 0 and 1000
which are evenly divisible by three OR seven.
//~ Print them on different
lines.
void PrintDiv3_7()
{
int i=0;
int cnt3=0; // counter of
period 3
int cnt7=0; // counter of period 7
while (i<1001)

{
if ((cnt3==0) || (cnt7==0))
printf("%d \n", i);

cnt3=(cnt3<2)?
cnt3+1 : 0;
cnt7=(cnt7<6)? cnt7+1 :
0;
i++;
};
printf("\n\n");
};

//~ 7) Write a loop which
prints out every third number between 11 and 21 inclusive.
void
PrintEveryThird()
{
int i;
for (i=11+2; i<22;
i+=3)
{
printf("%d ", i);
};
printf("\n\n");
};

//~ 8)
Write a loop which calculates 5 factorial.
void Calc5Fact()
{
int
i;
int f=1;
for(i=2; i<6; i++)
f*=i;

printf("5! =
%d\n\n",f);
};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!