Page 2 of 5 FirstFirst 12345 LastLast
Results 11 to 20 of 42

Thread: Kids Are Realy Getting Smarter Today

  1. #11
    Originally posted by Acecool@8 October 2003 - 19:14
    Code:
    // Comic2.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    
    int main(void)
    {
    	int count;
    
    	for(count=1;count<=500;count++)
     printf("I will not throw paper airplanes in class.\n");
    	return 0;
    }
    It works :-)

    The file weighs in at 168 kb (holy...)
    and opens a dos window, prints the stuff out, and yeah

    the guy forgot the \n newline else its all screwy
    Can you post it here http://www.uploadit.org/. try upx it and zipping it.


  2. Lounge   -   #12
    There is a lesson here...


    In the interest of getting it right, and because all programmers go through a bit of code review every now and then, I'm going to debug this program. There is a bug! The printf statement is not correct. It will not produce the output that the programmer desires. This program as written will create a mess.The line ...
    printf("I will not throw paper airplanes in class.");
    ... will produce the output you see below ...
    I will not throw paper airplanes in class.I will not throw paper airplanes in class.I will not throw paper airplanes in class.I will not throw paper airplanes in class.I will not throw paper airplanes in class.
    The programmer forgot to put a carriage return at the end of the string. It should be ...
    printf("I will not throw paper airplanes in class.\n");
    Now, the program will correctly produce the output formatted into the desired lines.
    I will not throw paper airplanes in class.
    I will not throw paper airplanes in class.
    I will not throw paper airplanes in class.
    I will not throw paper airplanes in class.
    I will not throw paper airplanes in class.
    The moral of this story is that you should always test your code. Never assume that it works. And absolutely DO NOT Publish the code without testing it first.

    Comic from FoxTrot ...

  3. Lounge   -   #13
    Poster
    Join Date
    Jan 2003
    Location
    Here
    Posts
    491
    Thats what I said >_<

    Code:
    Code:
    // Comic2.cpp &#58; Defines the entry point for the console application.
    //
    
    #include &#34;stdafx.h&#34;
    
    int main&#40;void&#41;
    {
    int count;
    
    for&#40;count=1;count&#60;=500;count++&#41;
     printf&#40;&#34;I will not throw paper airplanes in class.&#092;n&#34;&#41;;
    return 0;
    }
    Compiled..
    http://www.acecoolco.com/Comic2.zip


    Why do u think the teacher says nice try?
    Because the guy forgot the new line thing...

  4. Lounge   -   #14
    Cool. it nothin really useful but it`s still cool.
    Why do u think the teacher says nice try?
    Because the guy forgot the new line thing...
    If it is a computer science class maybe.

    if you don`t mind maybe i will share it on KaZaA

    oh ya here is the crack Here

  5. Lounge   -   #15
    Poster
    Join Date
    Jul 2003
    Location
    Duluth, MN
    Posts
    92
    Why do u think the teacher says nice try?
    Because the guy forgot the new line thing...
    haha cause he&#39;s trying to get out of writing "i will not throw paper airplanes in class" 500 times. so he wrote the code on the board to do it for him.

  6. Lounge   -   #16
    Originally posted by thedirtyd@9 October 2003 - 04:35
    Why do u think the teacher says nice try?
    Because the guy forgot the new line thing...
    haha cause he&#39;s trying to get out of writing "i will not throw paper airplanes in class" 500 times. so he wrote the code on the board to do it for him.
    the point was that the code written doesn&#39;t work
    it&#39;s incorrect as it stands, so the teacher says "nice try"
    <span style='font-size:14pt;line-height:100%'>BLAH</span>

    <span style='font-size:14pt;line-height:100%'>Wayne Rooney - A thug and a thief</span>

  7. Lounge   -   #17
    Maybe he should use perl instead to make it even a smaller code like

    Code:
    #&#33;/usr/bin/perl
    for &#40;&#036;count=1; &#036;count&#60;500; &#036;count++&#41;
    {
     print &#34;I will not throw paper airplanes in class.&#092;n&#34;;
    }
    which would result in this

    Btw I don&#39;t see the missing /n as error since he would need more space to write it only once per line In real code you would just use it to make the output more readable.

  8. Lounge   -   #18
    Originally posted by Darker@8 October 2003 - 22:18
    Maybe he should use perl instead to make it even a smaller code like

    Code:
    #&#33;/usr/bin/perl
    for &#40;&#036;count=1; &#036;count&#60;500; &#036;count++&#41;
    {
     print &#34;I will not throw paper airplanes in class.&#092;n&#34;;
    }
    which would result in this

    Btw I don&#39;t see the missing /n as error since he would need more space to write it only once per line In real code you would just use it to make the output more readable.
    Yeah, it would still be there 500 times, just all run together.

    Besides what do you think the chances are that a female middle school teacher would even be able to understand that.

  9. Lounge   -   #19
    I like my version better.



    Code:
    // Chalkboard.cpp &#58; Defines the entry point for the console application.
    //
    
    #include &#34;stdafx.h&#34;
    #include &#60;iostream.h&#62;
    
    int main&#40;void&#41;
    {
    
    	int count;
    
    	for&#40;count=1;count&#60;=500;count++&#41;
    	cout&#60;&#60;&#34;I will not throw paper airplanes in class.&#34;&#60;&#60;endl;
    	cout&#60;&#60;&#34;&#34;&#60;&#60;endl;
    
    	return 0;
    }


    Or how about with a while loop instead.



    Code:
    // Chalkboard.cpp &#58; Defines the entry point for the console application.
    //
    
    #include &#34;stdafx.h&#34;
    #include &#60;iostream.h&#62;
    
    int main&#40;void&#41;
    {
    
    	int count=1;
    
    	while&#40;count&#60;=500&#41;
    	{
     &nbsp;cout&#60;&#60;&#34;I will not throw paper airplanes in class.&#34;&#60;&#60;endl;
    
     &nbsp;++count;
    	}
    
    	return 0;
    }

  10. Lounge   -   #20
    4play's Avatar knob jockey
    Join Date
    Jan 2003
    Location
    London
    Age
    41
    Posts
    3,824
    Code:
    // Chalkboard.cpp &#58; Defines the entry point for the console application.
    //
    
    #include &#34;stdafx.h&#34;
    #include &#60;iostream.h&#62;
    
    int main&#40;void&#41;
    {
    
    int count;
    
    for&#40;count=1;count&#60;=500;count++&#41;
    cout&#60;&#60;&#34;I will not throw paper airplanes in class.&#34;&#60;&#60;endl;
    cout&#60;&#60;&#34;&#34;&#60;&#60;endl;
    
    return 0;
    }
    this will give you a space inbetween lines and the #include "stdafx.h" is not needed.

Page 2 of 5 FirstFirst 12345 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •