0

I'm working on a program that sorts magic the gathering cards, and I'm attempting to output text every x times, where x is specified by user. For example, the program counts down from 100, but only displays integers every 5 steps.

so the output would be 100 95 90 85 80 75 and so on.

I was trying to use an if statement for this, but I can't get my head around it. I'm new to programming, and I'm self taught, which is probably the root of my problems.

srallen87
  • 35
  • 1
  • 2
  • [See this thread](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) – M.M Sep 29 '14 at 03:23

2 Answers2

0

if ((x % 5) == 0) will trigger whenever x is divisible by 5 without a remainder. % refers to the following http://en.wikipedia.org/wiki/Modulo_operation

Neil Kirk
  • 21,327
  • 9
  • 53
  • 91
0
for(int i = 100; i >= 0; i -= x)
    std::cout << i << "\n";
Chris Drew
  • 14,926
  • 3
  • 34
  • 54
  • 2
    @Odedra It answers the question as I understand it. The question seems pretty clear to me. To critique or request clarification on an answer leave a comment below their answer. – Chris Drew Sep 29 '14 at 05:59