Answer to Question #320056 in C++ for Last one

Question #320056

Print out the cube values of the numbers ranging from 1 to 20 (inclusive). However, if the number is divisible by either 3 or 5, do not include them in printing and proceed with the next numbers. Tip: When skipping through special values, make use of the keyword continue and put them inside a conditional statement.

1
Expert's answer
2022-03-29T07:41:20-0400
#include <iostream>
using namespace std;

int main()
{
	for (int i = 1; i <= 20; i++) {
		if (i % 3 == 0 || i % 5 == 0) {
			continue;
		}
		else
		{
			cout << " Cube value of " << i << " = " << i * i * i << endl;
		}
	}
	return 0;
}

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog