Welcome, Guest. Please login or register.

Author Topic: using those tiny little LCD screens as monitors...  (Read 4824 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show all replies
Re: using those tiny little LCD screens as monitors...
« on: January 09, 2011, 01:41:35 PM »
Is it even the same loop?

"FOR C = 1 TO 2" looks like it would iterate once, whereas "for (int i=0; i<2; i++)" would iterate twice.

Of course, if you were sticking to C89, you'd not be allowed to use the declaration as statement syntax for the counter in the loop, you'd have to put an "int i;" at the top of the containing block. So, I'm going to assume your loop is C99 or C++ :D
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show all replies
Re: using those tiny little LCD screens as monitors...
« Reply #1 on: January 09, 2011, 02:26:28 PM »
Quote from: motorollin;605040
"FOR C = 1 TO 2" iterates twice - once when the value of C is 1, and again when the value is 2


Inclusive counting?!



Everything you need to know about what's wrong with BASIC is right there!
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show all replies
Re: using those tiny little LCD screens as monitors...
« Reply #2 on: January 09, 2011, 02:37:18 PM »
I guess I am just too used to the 0...N-1 method of counting ;)
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show all replies
Re: using those tiny little LCD screens as monitors...
« Reply #3 on: January 09, 2011, 02:42:01 PM »
Well, if you want to use the "inclusive" BASIC style looping, it's easy. Just change the < test for <= ;)
int p; // A