Looking for practice material?
Find thousands of archived packets FREE for practice and study use at the Quizbowl Packet Archive!
View unanswered posts | View active topics It is currently Wed Jan 17, 2018 2:13 pm



Post new topic Reply to topic  [ 13 posts ] 
Huge brain fart 
Author Message
Online
User avatar

Joined: Thu Apr 29, 2004
Posts: 6194
Location: In between the bright lights and the far unlit unknown (aka Johnson County, KS)
Post Huge brain fart
I spent a good 15-20 minutes trying to figure out why this for loop wouldn't work:

for(int i=0; i++; i<5)
{
//code
}

Talk about forgetting fundamental CS 53... especially when I've been using all sorts of loops several times this year


Mon Oct 23, 2006 6:15 pm
Profile WWW

Joined: Fri Apr 23, 2004
Posts: 2416
Location: MO
Post Huge brain fart
hahaha, nice one, Jeph.


Mon Oct 23, 2006 8:07 pm
Profile

Joined: Mon Mar 15, 2004
Posts: 5401
Location: Gower
Post Huge brain fart
and I thought my forgetting how to rotate something was bad.


Mon Oct 23, 2006 8:18 pm
Profile WWW

Joined: Fri Apr 23, 2004
Posts: 2416
Location: MO
Post Huge brain fart
yeah, I'm disgusted.


Mon Oct 23, 2006 9:01 pm
Profile
User avatar

Joined: Mon Feb 09, 2004
Posts: 4353
Location: Ozark, Missouri
Post Huge brain fart
Yep, I don't have a clue what that means, which actually makes this post rather pointless.


Mon Oct 23, 2006 9:28 pm
Profile WWW
Online
User avatar

Joined: Thu Apr 29, 2004
Posts: 6194
Location: In between the bright lights and the far unlit unknown (aka Johnson County, KS)
Post Huge brain fart
Do you have to take CS 74/78 (or is it required for anybody, for that matter or just a science elective for certain majors)?


Mon Oct 23, 2006 9:42 pm
Profile WWW
User avatar

Joined: Mon Feb 09, 2004
Posts: 4353
Location: Ozark, Missouri
Post Huge brain fart
I'll eventually have to take two CS courses.

UMR Math Department wrote:
Computer Science (select at least one from each of the following two groups)
( a ) Introduction to Programming (CS 53), Basic Scientific Programming (CS 073) and Computer Programming Laboratory (CS 077), Introduction to Programming  Methodology (CS 074) and Programming Methodology Lab (CS 078)
( b ) Data Structures I (CS 153), Discrete Mathematics for Computer Science (CS 158),  Introduction to Numerical Methods (CS 228)


Mon Oct 23, 2006 9:52 pm
Profile WWW

Joined: Mon Dec 27, 2004
Posts: 400
Post Huge brain fart
You missed a semicolon.


Mon Oct 23, 2006 10:01 pm
Profile
Online
User avatar

Joined: Thu Apr 29, 2004
Posts: 6194
Location: In between the bright lights and the far unlit unknown (aka Johnson County, KS)
Post Huge brain fart
jcarkeys wrote:
You missed a semicolon.

I'm pretty sure I didn't although it's very common for me to do so especially when I'm messing with strings


Mon Oct 23, 2006 10:06 pm
Profile WWW
Online
User avatar

Joined: Thu Apr 29, 2004
Posts: 6194
Location: In between the bright lights and the far unlit unknown (aka Johnson County, KS)
Post Huge brain fart
DeckardCain wrote:
I'll eventually have to take two CS courses.

UMR Math Department wrote:
Computer Science (select at least one from each of the following two groups)
( a ) Introduction to Programming (CS 53), Basic Scientific Programming (CS 073) and Computer Programming Laboratory (CS 077), Introduction to Programming  Methodology (CS 074) and Programming Methodology Lab (CS 078)
( b ) Data Structures I (CS 153), Discrete Mathematics for Computer Science (CS 158),  Introduction to Numerical Methods (CS 228)

I was thinking math might require more CS courses than the average department.


Mon Oct 23, 2006 10:09 pm
Profile WWW

Joined: Mon Dec 27, 2004
Posts: 400
Post Huge brain fart
ScoBo1987 wrote:
jcarkeys wrote:
You missed a semicolon.

I'm pretty sure I didn't although it's very common for me to do so especially when I'm messing with strings

Actually, the only language other than HTML that I have any reasonable grasp with is PHP, so I have no clue about C++ or anything else, that's just one of the things I know I've forgotten and I hear is a common thing in C based languages to forget. It sucks trying to debug hundreds of lines of code then realizing that you missed a semicolon on line 37.


Mon Oct 23, 2006 10:19 pm
Profile
Online
User avatar

Joined: Thu Apr 29, 2004
Posts: 6194
Location: In between the bright lights and the far unlit unknown (aka Johnson County, KS)
Post Huge brain fart
Yeah it's definitely very common especially when you're used to a language that is much much more lenient with syntax. It's really annoying when ONE missing semicolon confuses the compiler so much that it spits out hundreds of lines of errors.

If anybody's interested in my mistake, here's the syntax for a for loop:
for(action before first time, boolean to continue, what to do after each loop through)
{
//code
}

Basically what my code did was initialize i to 0, and then checked "i++" for true/false. Since i++ increments AFTER being used, it evaluated to 0 and thus false and it never entered the loop. If i had been anything else it would have been an infinite loop.

Whereas if written correctly it would have:
i=0
0<5, so do stuff, then increment i to 1
1<5, so do stuff, then increment i to 2
2<5, so do stuff, then increment i to 3
3<5, so do stuff, then increment i to 4
4<5, so do stuff, then increment i to 5
5 not less than 5, so don't loop again and go on


Mon Oct 23, 2006 10:26 pm
Profile WWW

Joined: Fri Apr 23, 2004
Posts: 2416
Location: MO
Post Huge brain fart
Right. *shrug* a simple mistake.


Tue Oct 24, 2006 7:44 am
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by STSoftware for PTF.
Translated by Maël Soucaze © 2010 phpBB.fr