Page 1 of 3 123 LastLast
Results 1 to 25 of 59

Thread: hey beagleman

  1. #1
    what about .. eyebrows God's Avatar
    Join Date
    Apr 2005
    Location
    among the people
    Posts
    49,776

    Default hey beagleman

    i might let you edit your profile if you tell my why this program gives me an infinite loop for all statements other than '.'



    #include <stdio.h>
    #include <stdlib.h>

    #define SENTINEL '.'

    int
    main()
    {

    char checksum, finalcheck;
    int sum, check;

    sum = 0;

    while(sum != 46)
    {

    printf("Enter a one-line message. Complete your message with a period.\n");
    printf("Enter a message: ");

    while(checksum != SENTINEL)
    {
    scanf("%c", &checksum);
    sum += (int)checksum;
    }
    if(sum != 46)
    { check = sum % 64;

    finalcheck = (char)(check + 32);

    printf("Checksum: %c\n", finalcheck);
    }
    else
    printf("Program ended.\n");


    }

    return(EXIT_SUCCESS);
    }

  2. #2
    what about .. eyebrows God's Avatar
    Join Date
    Apr 2005
    Location
    among the people
    Posts
    49,776

    Default

    i have to submit it at midnight so you have til then to find whats wrong and give me enough time to fix it.

  3. #3
    what about .. eyebrows God's Avatar
    Join Date
    Apr 2005
    Location
    among the people
    Posts
    49,776

    Default

    you did say the only way you could defeat dogar was in a computer competition. who knew it would come to fruition.

  4. #4
    princeso Kirby's Avatar
    Join Date
    Mar 2009
    Posts
    19,076

    Default

    God go to cosmo and ask flaming flamingo, he is real good with the code.

    He made astriods.

  5. #5
    I do things like get in a taxi and say, "The library, and step on it. Lord's Avatar
    Join Date
    Nov 2007
    Posts
    8,905

    Default

    what's astroids
    Well, I open my eyes and I see things. I've seen spirits moving through the walls. I've seen a vortex coming through the wall. I've seen amorphous little balls of light bouncing all around in the front yard through the window. I've seen giant bugs on the floor. I was in a hotel room in Amarillo, Texas, and all I remember is standing on the bed and seeing the whole wall in front of me filled with lights that were [makes popping sound] popping like popcorn out of the wall. Then I'll wake up and I go "Wow, I was standing on my bed and staring at this wall."

  6. #6
    I do things like get in a taxi and say, "The library, and step on it. Lord's Avatar
    Join Date
    Nov 2007
    Posts
    8,905

    Default

    this thread is exciting
    Well, I open my eyes and I see things. I've seen spirits moving through the walls. I've seen a vortex coming through the wall. I've seen amorphous little balls of light bouncing all around in the front yard through the window. I've seen giant bugs on the floor. I was in a hotel room in Amarillo, Texas, and all I remember is standing on the bed and seeing the whole wall in front of me filled with lights that were [makes popping sound] popping like popcorn out of the wall. Then I'll wake up and I go "Wow, I was standing on my bed and staring at this wall."

  7. #7
    princeso Kirby's Avatar
    Join Date
    Mar 2009
    Posts
    19,076

    Default

    You never played astriods?

  8. #8
    I do things like get in a taxi and say, "The library, and step on it. Lord's Avatar
    Join Date
    Nov 2007
    Posts
    8,905

    Default

    you mean like the 1980s computer game?
    Well, I open my eyes and I see things. I've seen spirits moving through the walls. I've seen a vortex coming through the wall. I've seen amorphous little balls of light bouncing all around in the front yard through the window. I've seen giant bugs on the floor. I was in a hotel room in Amarillo, Texas, and all I remember is standing on the bed and seeing the whole wall in front of me filled with lights that were [makes popping sound] popping like popcorn out of the wall. Then I'll wake up and I go "Wow, I was standing on my bed and staring at this wall."

  9. #9
    Beginning Trainer
    Join Date
    Mar 2012
    Posts
    4

    Default

    Wow..
    Doesn't give me much time..
    I will do my best to figure it out.. :L
    If I get an answer, I'll post it.

  10. #10
    Defenestration is imminent pichubro's Avatar
    Join Date
    Mar 2005
    Location
    Kaleidoscope Of Mathematics
    Posts
    18,290

    Default

    I think Yoshi just revealed himself as beagleman.

  11. #11
    VVVV Look 4 balls Khaous's Avatar
    Join Date
    Feb 2010
    Posts
    3,277

    Default

    you have 2 hours if gods in my timezone. GET CODING MAN

  12. #12
    Registered Users Regular Rayne's Avatar
    Join Date
    Mar 2009
    Posts
    8,586

    Default

    indent your code. its painful to read.

  13. #13
    Registered Users Regular Rayne's Avatar
    Join Date
    Mar 2009
    Posts
    8,586

    Default

    also i dont understand what youre trying to do here. at first i assumed you were trying to count the number of characters but youre doing weird arithmetic with sum. either way, i think the cause of the infinite loop is that after the second while, though youre asking them to type a sentence, youre only scanning the first character which will never be a period unless you just enter a period. the loop only stops when the scanned character is a period so yeah infinite loop for anything other than a period.

  14. #14
    The One and Only trixie's Avatar
    Join Date
    Oct 2004
    Location
    In your dreams.
    Posts
    10,106

    Default

    You need to initialize checksum before using it to check a condition!

    ^ First thought. Reading the rest now.
    Originally made by LM:


    ~ I have said nothing because there is nothing I can say that would describe how I feel as perfectly as you deserve it. -- Kyle Schmidt ~

    ~Silence is one of the hardest arguments to refute. -- Josh Billings ~

    * dragon_berry**Fallen_Wings*

  15. #15
    The One and Only trixie's Avatar
    Join Date
    Oct 2004
    Location
    In your dreams.
    Posts
    10,106

    Default

    Quote Originally Posted by Rayne View Post
    also i dont understand what youre trying to do here. at first i assumed you were trying to count the number of characters but youre doing weird arithmetic with sum.
    Yeah, why are you converting the characters to their integer values and adding them together?
    Originally made by LM:


    ~ I have said nothing because there is nothing I can say that would describe how I feel as perfectly as you deserve it. -- Kyle Schmidt ~

    ~Silence is one of the hardest arguments to refute. -- Josh Billings ~

    * dragon_berry**Fallen_Wings*

  16. #16
    The One and Only trixie's Avatar
    Join Date
    Oct 2004
    Location
    In your dreams.
    Posts
    10,106

    Default

    Quote Originally Posted by God View Post
    while(sum != 46)
    {

    printf("Enter a one-line message. Complete your message with a period.\n");
    printf("Enter a message: ");

    while(checksum != SENTINEL)
    {
    scanf("%c", &checksum);
    sum += (int)checksum;
    }


    if(sum != 46)
    { check = sum % 64;

    finalcheck = (char)(check + 32);

    printf("Checksum: %c\n", finalcheck);
    }
    else
    printf("Program ended.\n");
    }

    }
    Does this not mean that when control comes out of the while loop, sum= 46? It's never going to enter the if condition then. What's 46 for, and can it be changed to while(sum<=46) or something.
    Last edited by trixie; 03-22-2012 at 03:07 AM. Reason: Indentation.... didn't work :(
    Originally made by LM:


    ~ I have said nothing because there is nothing I can say that would describe how I feel as perfectly as you deserve it. -- Kyle Schmidt ~

    ~Silence is one of the hardest arguments to refute. -- Josh Billings ~

    * dragon_berry**Fallen_Wings*

  17. #17
    Registered Users Regular Rayne's Avatar
    Join Date
    Mar 2009
    Posts
    8,586

    Default

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    #define SENTINEL '.'
    
    int main()
    {
    
        char checksum, finalcheck;
        int sum, check;
    
        sum = 0;
    
        while(sum != 46)
        {
    
            printf("Enter a one-line message. Complete your message with a period.\n");
            printf("Enter a message: ");
    
            while(checksum != SENTINEL)
            {
                scanf("%c", &checksum);
                sum += (int)checksum;
            }
            if(sum != 46)
            { 
                check = sum % 64;
    
                finalcheck = (char)(check + 32);
    
                printf("Checksum: %c\n", finalcheck);
            }
            else
                printf("Program ended.\n");
    
    
        }
    
        return(EXIT_SUCCESS);
    }

  18. #18
    The One and Only trixie's Avatar
    Join Date
    Oct 2004
    Location
    In your dreams.
    Posts
    10,106

    Default

    How did you do that, Rayne?
    Originally made by LM:


    ~ I have said nothing because there is nothing I can say that would describe how I feel as perfectly as you deserve it. -- Kyle Schmidt ~

    ~Silence is one of the hardest arguments to refute. -- Josh Billings ~

    * dragon_berry**Fallen_Wings*

  19. #19
    Registered Users Regular Rayne's Avatar
    Join Date
    Mar 2009
    Posts
    8,586

    Default

    [code] tags

  20. #20
    The One and Only trixie's Avatar
    Join Date
    Oct 2004
    Location
    In your dreams.
    Posts
    10,106

    Default

    Oh yeah, it didn't strike me because I've never used it
    Originally made by LM:


    ~ I have said nothing because there is nothing I can say that would describe how I feel as perfectly as you deserve it. -- Kyle Schmidt ~

    ~Silence is one of the hardest arguments to refute. -- Josh Billings ~

    * dragon_berry**Fallen_Wings*

  21. #21
    Registered Users Regular Rayne's Avatar
    Join Date
    Mar 2009
    Posts
    8,586

    Default

    i wasnt sure if vb had it. it was a shot in the dark.

  22. #22
    Registered Users Regular Rayne's Avatar
    Join Date
    Mar 2009
    Posts
    8,586

    Default

    Quote Originally Posted by Kirby View Post
    You never played astriods?
    ASTEROIDS you moron

  23. #23
    The One and Only trixie's Avatar
    Join Date
    Oct 2004
    Location
    In your dreams.
    Posts
    10,106

    Default

    Have you learnt any C yet?
    Originally made by LM:


    ~ I have said nothing because there is nothing I can say that would describe how I feel as perfectly as you deserve it. -- Kyle Schmidt ~

    ~Silence is one of the hardest arguments to refute. -- Josh Billings ~

    * dragon_berry**Fallen_Wings*

  24. #24
    Registered Users Regular Rayne's Avatar
    Join Date
    Mar 2009
    Posts
    8,586

    Default

    do you read what you write? what the hell is ass-tree-odds?

  25. #25
    Registered Users Regular Rayne's Avatar
    Join Date
    Mar 2009
    Posts
    8,586

    Default

    Quote Originally Posted by trixie View Post
    Have you learnt any C yet?
    dont know c. i am competent in c++ and know a fair bit of python and php.

Page 1 of 3 123 LastLast

Posting Permissions

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