Tilted Forum Project Discussion Community

Tilted Forum Project Discussion Community (https://thetfp.com/tfp/)
-   Tilted Technology (https://thetfp.com/tfp/tilted-technology/)
-   -   C Foxtrot Comic (https://thetfp.com/tfp/tilted-technology/30002-c-foxtrot-comic.html)

BuddyHawks 10-03-2003 03:20 PM

C Foxtrot Comic
 
I was reading the Friday Oct. 8th Chicago Tribune and saw this funny Foxtrot comic.
http://images.ucomics.com/comics/ft/2003/ft031003.gif
I wasn't sure if this would fit better in Humor, but I figured it would be more appreciated here.
:D :D :D

spectre 10-03-2003 03:25 PM

That's awesome. :lol:

juanvaldes 10-03-2003 03:29 PM

I love it :)

man I could have use this back in 3ed grade....he could stand to tighten up that code a bit too ;)

nickdman 10-03-2003 04:12 PM

Nice, I need that right now

Latch 10-03-2003 04:30 PM

That was great.. thanks!

The_Dude 10-03-2003 05:01 PM

nice! that's one smart kid

kel 10-03-2003 07:33 PM

Quote:

Originally posted by juanvaldes
I love it :)

man I could have use this back in 3ed grade....he could stand to tighten up that code a bit too ;)

LOL... didn't even pick up on that.

Cynthetiq 10-03-2003 08:26 PM

:) i did this in my second year in HS. Had to write,"I will not make chin music in class." 100 times... i convinced the teacher that i had actually typed it 100 times, since I had a diasy wheel printer.

After that.... everyone started doing it. I had started a trend, and he wasn't all that happy with it. He then only started to collect hand written only.

Melllvar 10-03-2003 08:34 PM

I've got UNIX underpants!

no, wait, wrong strip. :)

Fremen 10-03-2003 09:19 PM

I got it and I don't understand coding.
Am I a genius all of a sudden? *looks around* Nope! :p

Thanks, BuddyHawks, pretty funny stuff.

oblar 10-03-2003 09:22 PM

Cynthique, that is pretty cool.. I never had a teacher make us do the repitition on computer.. It was always hand written :(

nice strip :) I always love fox trot

Marburg 10-04-2003 08:48 AM

he forgot the \n :p

Peutetre 10-04-2003 09:32 AM

hehe.. that's funny.. =)

oberon 10-04-2003 12:50 PM

LOL, good find! Agreed, he did forget the \n... :p :D

Fallon 10-04-2003 05:31 PM

I should print that out and put it on somethin and show my programming concepts teacher...
Thanks a bunch

Melraidin 10-04-2003 10:33 PM

Still nasty code. If he's only using the counter inside the for loop, should definitly be defined inside of it (assuming C++, and not C):

for ( int count = 0; count < 500; count++ )

Also, of course, the code in the strip's only going to print it 499 times. Think the teacher'll count 'em?

Flippy 10-04-2003 11:24 PM

Nah, it's C (stdio, not iostream) :)

Also, I believe it's running 500 times because he used <= instead of <.

Good pick up on the '\n' though ... i totally missed that when i read this in the paper lol

TheClarkster 10-04-2003 11:54 PM

Quote:

Originally posted by Marburg
he forgot the \n :p
Haha I caught that too...
Is it good when we catch stuff like this in a comic?

rubicon 10-05-2003 01:15 PM

lol

Regziever 10-06-2003 09:03 AM

Hehehe... I've just started learning C++ but that was really funny.. Nice find!

Marburg 10-06-2003 11:06 AM

actually, now that I look at it he forgot the braces { } in the for loop.

Jeebus, Jason is falling apart!
;)

ps. My CSci prof loved it.

hawkeye 10-07-2003 08:14 PM

Quote:

Originally posted by Marburg
actually, now that I look at it he forgot the braces { } in the for loop.

Jeebus, Jason is falling apart!
;)

ps. My CSci prof loved it.

you don't actually need the {} when yoiu are looping only one line of code.

hey, juan, how would//should he tighten it up?

juanvaldes 10-08-2003 03:43 PM

C
Code:

#include &lt;stdio.h&gt;
int main(void) {
    for(int count=1; count<=500; count++){ printf("I will not throw paper airplaces in class.\n"); }
    return 0;
}

C++
Code:

#include &lt;iostream&gt;
void main() { for(int count=1; count<=500; count++){ cout << "I will not throw paper airplaces in class." << endl; } }

Just two of the many ways you can play with it...




Had to edit to make the includes show up. It was driving me nuts

charliex 10-08-2003 08:28 PM

juanvaldes thats invalid C, plus making everything appear on one line isn't doing anything to affect code performance, but does make it harder to read.

adding braces is arguably neater to stop running the risk of a later programmer adding more lines and it not working as one might expect , but if its a finalized app its mainly syntactic sugar, though it is something i would recommend doing and do.

He may have deliberately left out the \n as that would fill the entire stdout with the phrase.

and they say programmers over analyze :)

juanvaldes 10-08-2003 11:22 PM

I did not mean to imply faster code, just shorter. A friend did one using a while loop with trinary operators in it just for the hell of it, pretty funny.

krazykemist 10-09-2003 03:16 AM

A little different but would this work as well?

Code:

#include &lt;stdio.h&gt;
 main()
  {int count; count=1; while (count <= 500)
    {++count;printf("I will not throw paper airplanes in class.\n");
    }
  return 0;
  }


Had to edit to make the include show up

hrdwareguy 10-09-2003 04:18 AM

Quote:

Originally posted by krazykemist
A little different but would this work as well?

Code:

#include &lt;stdio.h&gt;
 main()
  {int count; count=1; while (count <= 500)
    {++count;printf("I will not throw paper airplanes in class.\n");
    }
  return 0;
  }


You would only get it printed out 499 times. Count starts at 1 and before you do anything with it you are incrementing it to 2 so you loose 1 line of print.

BuddyHawks 10-09-2003 11:56 AM

Yeah,

for
whlie
do while

all the loops can be applied.

charliex 10-09-2003 08:42 PM

Quote:

You would only get it printed out 499 times. Count starts at 1 and before you do anything with it you are incrementing it to 2 so you loose 1 line of print.
Not true, its <= so it will do 500 times, starting loops at 1 is often the sign of a pascal programmer or such switching to C, the ending value will be 501, not 500. so from 2 to 501

int i=500;
while(i--) {
.....
}
simple, uses a faster test which is generally implemented as a single instruction, the whole loop can be done in one instruction on a pc (ignoring the inital load), though some optimizing compilers will pick up on that the for loop and fix it.

jujueye 10-10-2003 08:35 AM

Quote:

Originally posted by Marburg
he forgot the \n :p
Good point. It would all run together. My C instructor would kick his ass for that one....!

hrdwareguy 10-10-2003 01:47 PM

Quote:

Originally posted by charliex
Not true, its <= so it will do 500 times, starting loops at 1 is often the sign of a pascal programmer or such switching to C, the ending value will be 501, not 500. so from 2 to 501


I was referring to krazykemist's post where the counter started at 1 then went into the loop. First thing he did in the loop was increment the counter to 2, then print. So you would end up with this at the bottom of the loop:

count&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;number of times printed
2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1
3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2
4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3
.
.
.
498&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 497
499&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 498
500&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 499
501&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End of loop
</pre>
So you would only end up with the sentence being printed 499 times.

charliex 10-10-2003 03:04 PM

hrdwareguy: nope, you are missing the key point,
2 to 501 is inclusive which equals 500 steps.

example

say it was i=1 to i<=5 instead of 500 so
int i ; while (i<=5){ i++ };

program starts :
i = 1

:loop starts

is i less than or equal to 5 ? i=1, so yes, continue.

i is incremented to 2
"message is printed' (1rst time)

go back to top of loop

is i less than or equal to 5 ? i=2 so yes, continue.

i is incremented , is now 3
"message is printed' ( 2nd time)

go back to top of loop

is i less than or equal to 5 ? i=3 so yes, continue.

i is incremented , is now 4
"message is printed' (3rd time)

go back to top of loop

is i less than or equal to 5 ? i=4 so yes, continue.

i is incremented , is now 5
"message is printed' (4th time)

go back to top of loop

is i less than or equal to 5 ? i=5 so yes, continue. (not the key part here is less than *or* equal to 5 = 5 so its true, so it meets the condition.

i is incremented , is now 6
"message is printed' (5th time)

go to start of loop

is i less than or equal to 5 ? i is now 6, so stop the loop since 6 <= 5 is false (0)

5 messages were printed.

This is quite a common mistake made for junior or new programmers, its similar to people using the 5th element on an array defined as say int[5] and then using i = array[5]; which is of course the 6th element.

hrdwareguy 10-13-2003 02:54 AM

Quote:

Originally posted by charliex
hrdwareguy: nope, you are missing the key point,
2 to 501 is inclusive which equals 500 steps.

Charliex:

I understand this. The original code I was referring to did not say <= 501 it said <=500. Go back and look at it if you want to. Since the original code I was referring to was therefore 2 to 500, I still stand by my statement that it will only print 499 times.

charliex 10-13-2003 11:15 AM

hrdwareguy: dear oh dear, please read over my comment

Quote:

say it was i=1 to i<=5 instead of 500 so "
Its 2 to 501 because of the increment inside of the loop, before the while is tested.

For instance my example is 1 to 5 but it runs as 2 to 6. so when you do <=n , n ends up being + 1

i really don't know how to simplify it anymore so that you can understand it.

So heres another proof (hope this posts correctly) i added my comments with a // to the actual session

Code:


// show contents of file test.cpp ( i copied and pasted from hrdwareguys quote exactly as was )
[C:\4nt]type test.cpp
#include &lt;stdio.h&gt;
 main()
  {int count; count=1; while (count <= 500)
    {++count;printf("I will not throw paper airplanes in class.\n");
    }
  return 0;
  }

// compile it
[C:\4nt]cl -nologo test.cpp
test.cpp

// run it with a redirect into a file
[C:\4nt]test >out.txt

//run wc, which is a wordcounter with line count
[C:\4nt]wc out.txt

out.txt:            Words: 4000      Lines: 500        Chars: 21000

Lines = 500 , as expected, i could post the whole output but that'd be silly.

I could post the exe if you still don't believe me, but if you go over the loop i typed it in the previous comment it will be come obvious to you (since it does seem like you didn't read it through as the comment you made indicates you didn't see where i said <=500 twice)

krazykemist 10-13-2003 11:32 AM

I'm never going to post any code in this forum again. :)

hrdwareguy 10-13-2003 11:32 AM

Charliex: OK, I get it, you are correct. I was getting getting confused because I usually increment my loops at the bottom. Got one to many tests in there.

By the way, I edited your post for the sole purpose of making the &lt;stdio.h&gt; display correctly.

krazykemist 10-13-2003 11:53 AM

hrdwareguy-
How did you get it to include the #include?
I tried like 3 different ways.
Just curious.

charliex 10-13-2003 12:01 PM

Code:

#include &lt;stdio.h&gt;
 main()
  {int count; count=1; do
    {++count;printf("I will not throw paper airplanes in class.\n");
    }while(count <= 500);
  return 0;
  }

You mean like that ? (sorry i never found out how to quote the <'s properly in forum speak)

It would still print 500 lines.

hrdwareguy 10-13-2003 12:12 PM

Quote:

Originally posted by krazykemist
hrdwareguy-
How did you get it to include the #include?
I tried like 3 different ways.
Just curious.

You have to use the HTML tags. & l t ; is the &lt; and & g t ; is the &gt;

hrdwareguy 10-13-2003 12:17 PM

Actuall in my mind it was something like this:
Code:

#include &lt;stdio.h&gt;
int main(void)
{
    int count=1;
    while(count <=500)
    {
          ++count; //as a one time increment
          printf("I will not throw paper airplanes in class\n");
          ++count;//as I usuall do my incrementing at the bottom
    }
    return 0;
}



All times are GMT -8. The time now is 07:59 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360