Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. It isn't Friday but how about a code quest anyway

It isn't Friday but how about a code quest anyway

Scheduled Pinned Locked Moved The Lounge
csharpandroidcomtoolsquestion
10 Posts 9 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Ennis Ray Lynch Jr
    wrote on last edited by
    #1

    I want to see do loops that are not pre-initialized and do not rely on looping on and that do not rely on a true in the while condition? Why do I want to see it? Well, do loops are cool but not if you have to have the same line of code twice. Can you author a do loop that is not initialized outside of the block, does actual work, and needs a loop? (Remember, functions and methods like getDate() or DateTime.Now can't be used because they have to be initialized somehwere)

    Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

    J D N M D 8 Replies Last reply
    0
    • E Ennis Ray Lynch Jr

      I want to see do loops that are not pre-initialized and do not rely on looping on and that do not rely on a true in the while condition? Why do I want to see it? Well, do loops are cool but not if you have to have the same line of code twice. Can you author a do loop that is not initialized outside of the block, does actual work, and needs a loop? (Remember, functions and methods like getDate() or DateTime.Now can't be used because they have to be initialized somehwere)

      Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

      J Offline
      J Offline
      Jim Crafton
      wrote on last edited by
      #2

      No homework questions here please!!!

      ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

      E 1 Reply Last reply
      0
      • J Jim Crafton

        No homework questions here please!!!

        ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

        E Offline
        E Offline
        Ennis Ray Lynch Jr
        wrote on last edited by
        #3

        :) Actually, the homework version of the question is trivial, converting a while loop to a do loop or the reverse (ok, I thought it was trivial until I was a T.A. and graded what kids turned in), I think my question is non-trivial enough to be a fun challenge.

        Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

        1 Reply Last reply
        0
        • E Ennis Ray Lynch Jr

          I want to see do loops that are not pre-initialized and do not rely on looping on and that do not rely on a true in the while condition? Why do I want to see it? Well, do loops are cool but not if you have to have the same line of code twice. Can you author a do loop that is not initialized outside of the block, does actual work, and needs a loop? (Remember, functions and methods like getDate() or DateTime.Now can't be used because they have to be initialized somehwere)

          Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

          D Offline
          D Offline
          David1987
          wrote on last edited by
          #4

          I don't know about that, but I quite often have do-loops because I can often guarantee that the condition is true the first time around (so no need to check it)

          1 Reply Last reply
          0
          • E Ennis Ray Lynch Jr

            I want to see do loops that are not pre-initialized and do not rely on looping on and that do not rely on a true in the while condition? Why do I want to see it? Well, do loops are cool but not if you have to have the same line of code twice. Can you author a do loop that is not initialized outside of the block, does actual work, and needs a loop? (Remember, functions and methods like getDate() or DateTime.Now can't be used because they have to be initialized somehwere)

            Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

            N Offline
            N Offline
            Nemanja Trifunovic
            wrote on last edited by
            #5

            Ennis Ray Lynch, Jr. wrote:

            do loops that are not pre-initialized and do not rely on looping on and that do not rely on a true in the while condition?

            Maybe I am still trying to wake up, but can't understand a thing. Do not rely on looping on? Loops are not pre-initialized? :~

            utf8-cpp

            1 Reply Last reply
            0
            • E Ennis Ray Lynch Jr

              I want to see do loops that are not pre-initialized and do not rely on looping on and that do not rely on a true in the while condition? Why do I want to see it? Well, do loops are cool but not if you have to have the same line of code twice. Can you author a do loop that is not initialized outside of the block, does actual work, and needs a loop? (Remember, functions and methods like getDate() or DateTime.Now can't be used because they have to be initialized somehwere)

              Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

              M Offline
              M Offline
              Mladen Jankovic
              wrote on last edited by
              #6

              How 'bout almighty goto?

              [Genetic Algorithm Library]

              1 Reply Last reply
              0
              • E Ennis Ray Lynch Jr

                I want to see do loops that are not pre-initialized and do not rely on looping on and that do not rely on a true in the while condition? Why do I want to see it? Well, do loops are cool but not if you have to have the same line of code twice. Can you author a do loop that is not initialized outside of the block, does actual work, and needs a loop? (Remember, functions and methods like getDate() or DateTime.Now can't be used because they have to be initialized somehwere)

                Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

                D Offline
                D Offline
                Dan Neely
                wrote on last edited by
                #7

                Note sure if this is counts because it relies on values not being initialized when entering the loop...

                //calculates 5*5
                int? product;
                int? counter;
                do
                {
                int a = 5;
                int b = 5;
                if (product.HasValue)
                Product.Value+=a;
                else Product.Value = a;

                if (counter.HasValue)
                counter.Value+=1;
                else counter.Value = 1;
                }
                while (counter < b)

                3x12=36 2x12=24 1x12=12 0x12=18

                1 Reply Last reply
                0
                • E Ennis Ray Lynch Jr

                  I want to see do loops that are not pre-initialized and do not rely on looping on and that do not rely on a true in the while condition? Why do I want to see it? Well, do loops are cool but not if you have to have the same line of code twice. Can you author a do loop that is not initialized outside of the block, does actual work, and needs a loop? (Remember, functions and methods like getDate() or DateTime.Now can't be used because they have to be initialized somehwere)

                  Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

                  Y Offline
                  Y Offline
                  Yusuf
                  wrote on last edited by
                  #8

                  Even after many cups of coffee, I've very slow morning. My head is very stiff, anyways let us see.

                  Ennis Ray Lynch, Jr. wrote:

                  do loops that are not pre-initialized

                  That is not hard, it can be initialized inside the loop?

                  Ennis Ray Lynch, Jr. wrote:

                  and do not rely on looping on

                  I have no idea what you meant? loops that don't need loop? huh?

                  Ennis Ray Lynch, Jr. wrote:

                  do not rely on a true in the while condition

                  huh? then you need the mighty for(;;)

                  Yusuf May I help you?

                  1 Reply Last reply
                  0
                  • E Ennis Ray Lynch Jr

                    I want to see do loops that are not pre-initialized and do not rely on looping on and that do not rely on a true in the while condition? Why do I want to see it? Well, do loops are cool but not if you have to have the same line of code twice. Can you author a do loop that is not initialized outside of the block, does actual work, and needs a loop? (Remember, functions and methods like getDate() or DateTime.Now can't be used because they have to be initialized somehwere)

                    Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

                    P Offline
                    P Offline
                    PIEBALDconsult
                    wrote on last edited by
                    #9

                    Yes, yes of course. (Unless I misunderstand the question.) Although I rarely use do loops at all. Here's one I wrote long ago (2003), it could use some work:

                    private static int
                    exec_many
                    (
                    PIEBALD.Data.IDatabaseConnector dbc
                    )
                    {
                    int result = 0 ;

                    string intext  = ""        ;
                    string prompt  = "\\nDBT> " ;
                    string command = ""        ;
                    
                    System.Console.WriteLine ( "Enter SQL commands here\\nEnd each command with a semi-colon (;)\\nType \\"exit\\" to stop\\n" ) ;
                    
                    do
                    {
                        System.Console.Write ( prompt ) ;
                        intext = System.Console.ReadLine() ;
                    
                        if ( intext == null )
                        {
                            if ( command == "" )
                            {
                                intext = "exit" ;
                            }
                            else
                            {
                                intext = ";" ;
                            }
                        }
                    
                        if ( intext.StartsWith ( "--" ) )
                        {
                            continue ;
                        }
                    
                        prompt = "...> " ;
                    
                        command += " " + intext ;
                    
                        if ( (intext.Trim()).EndsWith ( ";" ) )
                        {
                            result += exec\_one ( dbc , command ) ;
                    
                            command = "" ;
                            prompt = "\\nDBT> " ;
                        }
                    }
                    while ( intext.ToUpper() != "EXIT" ) ;
                    
                    System.Console.WriteLine ( "Thank you" ) ;
                    
                    return ( result ) ;
                    

                    }

                    1 Reply Last reply
                    0
                    • E Ennis Ray Lynch Jr

                      I want to see do loops that are not pre-initialized and do not rely on looping on and that do not rely on a true in the while condition? Why do I want to see it? Well, do loops are cool but not if you have to have the same line of code twice. Can you author a do loop that is not initialized outside of the block, does actual work, and needs a loop? (Remember, functions and methods like getDate() or DateTime.Now can't be used because they have to be initialized somehwere)

                      Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

                      D Offline
                      D Offline
                      Dwayne J Baldwin
                      wrote on last edited by
                      #10

                      A lasso or a noose. Care to provide an example of what you don't want?

                      Dwayne J. Baldwin

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups