Loop Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • logicode
    New Member
    • Apr 2007
    • 22

    Loop Question

    I need a loop that can be put in 3 instances. I am not sure which loop I can find and I dont want to use a switch statement so can you help? I Already know the code just the loop for it.
    Basically I want to

    if (blabla)
    { then do this};
    if (blabla2)
    { then do this};
    if (blabla3)
    {then do this};
  • logicode
    New Member
    • Apr 2007
    • 22

    #2
    Can someone give me an answer please?

    Comment

    • jj555s
      New Member
      • Mar 2007
      • 36

      #3
      I'm not sure what you're trying to do...

      Comment

      • ilikepython
        Recognized Expert Contributor
        • Feb 2007
        • 844

        #4
        Originally posted by logicode
        I need a loop that can be put in 3 instances. I am not sure which loop I can find and I dont want to use a switch statement so can you help? I Already know the code just the loop for it.
        Basically I want to

        if (blabla)
        { then do this};
        if (blabla2)
        { then do this};
        if (blabla3)
        {then do this};
        What do you mean by a loop? Do you want to continue looping through the if statements until something happens? If not then what are you trying to do?

        Comment

        • jj555s
          New Member
          • Mar 2007
          • 36

          #5
          I'm guessing since you don't want a case switch
          that you're looking for if, else?

          Comment

          • sushanthakre
            New Member
            • Apr 2007
            • 1

            #6
            hey ..how to print all possible combinations of a,b,c.plz help

            Comment

            • massdeletion101
              New Member
              • Mar 2007
              • 23

              #7
              Originally posted by logicode
              I need a loop that can be put in 3 instances. I am not sure which loop I can find and I dont want to use a switch statement so can you help? I Already know the code just the loop for it.
              Basically I want to

              if (blabla)
              { then do this};
              if (blabla2)
              { then do this};
              if (blabla3)
              {then do this};
              Seems to me that if loops aren't a good way to go. You should use a case or switch statement for this kind of work, because loops are better for repition on a current condition.

              Comment

              • Azka
                New Member
                • Mar 2007
                • 3

                #8
                what the action you want?

                i think loop can be done by combine using "loop for" and if..

                this can be solved when we know what you want to display

                Comment

                • Azka
                  New Member
                  • Mar 2007
                  • 3

                  #9
                  what kind you want to display? char or int..

                  this command to display the int..
                  printf("%d %d %d",a,b,c);

                  Comment

                  • Poulami
                    New Member
                    • Apr 2007
                    • 2

                    #10
                    U cn use a nested while loop.

                    Comment

                    • JosAH
                      Recognized Expert MVP
                      • Mar 2007
                      • 11453

                      #11
                      Originally posted by sushanthakre
                      hey ..how to print all possible combinations of a,b,c.plz help
                      Have a look at this little table and see if you can use it:
                      Code:
                      A B C
                      -----
                      0 0 0 -
                      0 0 1 C
                      0 1 0 B
                      0 1 1 BC
                      1 0 0 A
                      1 0 1 AC
                      1 1 0 AB
                      1 1 1 ABC
                      kind regards,

                      Jos

                      Comment

                      • guptashiitd
                        New Member
                        • Apr 2007
                        • 5

                        #12
                        Originally posted by logicode
                        I need a loop that can be put in 3 instances. I am not sure which loop I can find and I dont want to use a switch statement so can you help? I Already know the code just the loop for it.
                        Basically I want to

                        if (blabla)
                        { then do this};
                        if (blabla2)
                        { then do this};
                        if (blabla3)
                        {then do this};
                        try to use the if=else if loops

                        Comment

                        Working...