qbasic programming trouble (again)

Discussion in 'Software' started by ashykatia, Mar 4, 2003.

  1. ashykatia

    ashykatia Private E-2

    Hey there, long time no see, all. I want you all to know that helped me last time that the rounding trouble I had was easily recitified with a "PRINT USING" statement. Well, onward and upward.....
    I am know in the deep throes of programming hell, and I welcome it, but this one has me pissed and aggravated.
    I have to write a program that recognizes a palindrome.(same word OR sentence forward and backwards). I have the code witten what I thought was perfect. The first time I run the program, it turns out OK. But the next time through, it tells me the same word I had just entered isn't a palindrome. It has me unnerved. Here it what I have:

    FOR count = LEN(palin$) to 1 step - 1
    palin1$ = MID$(palin$, count, 1)+palin1$
    NEXT
    IF palin1$=palin$ THEN
    PRINT"you have entered a palindrome"
    ELSE
    PRINT "nope, try again"
    END IF

    What did I do wrong????

    Thanks....you are all great
    ;)
     
  2. iamien

    iamien Cptn "Eh!"

    Try having it read the entered word backwards, then testing for equality.
     
  3. ashykatia

    ashykatia Private E-2

    I thought that's what the "step-1" did.
     
  4. iamien

    iamien Cptn "Eh!"

    sorry was a bit tierd when i posted, hmm dunno, i'll post if i see anything
     
  5. lesrae

    lesrae Private E-2

    Try changing the second line to read:

    palin1$ = palin1$ + MID$(palin$, count, 1)

    It seems to work, it's normal to add a variable to itself in this order, not as you have it.

    For a visual check, print both of the strings after your NEXT command:

    print palin$
    print palin1$
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds