Answer to Question #280144 in C for kim

Question #280144

We've already done looping through a series of numbers and printing out its squares, so how about we level it up and go with cubes this time?


I have a condition though; I don't want to be associated with numbers that are divisible by 3 or 5 so if an integer is divisible by either of the two, don't make their cube values appear on the screen, please.


Care to fulfill my request?


Instructions:

  1. Print out the cube values of the numbers ranging from 1 to 1000 (inclusive). However, if the number is divisible by either 3 or 5, do not include them in printing and proceed with the next numbers.
  2. Tip: When skipping through special values, make use of the keyword continue and put them inside a conditional statement.
1
Expert's answer
2021-12-17T18:18:18-0500
#include <stdio.h>
#include <string.h>
#include <ctype.h>


int main(){
	int i;
	for(i=1;i<=1000;i++){
		if (i % 3 == 0 || i % 5 == 0){
			continue;
		}
		printf("%d^3 = %d\n",i,(i*i*i));
	}




	getchar();
	getchar();
	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
APPROVED BY CLIENTS