Reply
Results 1 to 12 of 12
  1. #1
    Registered User beanlet21's Avatar
    Join Date: Nov 2011
    Age: 31
    Posts: 1,384
    Rep Power: 0
    beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank)
    beanlet21 is offline

    c programming question

    does this language have a limit on how many nested if-else-if statements you can have?
    i have like 40 different statements that look like
    if(){
    else if()
    else if()
    else if()
    else if()....}


    else

    it is like one of those russian dolls, and I'm wondering if my program will crash on me or something.
    Reply With Quote

  2. #2
    Banned nuliftr's Avatar
    Join Date: Aug 2013
    Age: 52
    Posts: 136
    Rep Power: 0
    nuliftr is the lowest scum of the boards. (Worst Rank) nuliftr is the lowest scum of the boards. (Worst Rank) nuliftr is the lowest scum of the boards. (Worst Rank) nuliftr is the lowest scum of the boards. (Worst Rank) nuliftr is the lowest scum of the boards. (Worst Rank) nuliftr is the lowest scum of the boards. (Worst Rank) nuliftr is the lowest scum of the boards. (Worst Rank) nuliftr is the lowest scum of the boards. (Worst Rank) nuliftr is the lowest scum of the boards. (Worst Rank) nuliftr is the lowest scum of the boards. (Worst Rank) nuliftr is the lowest scum of the boards. (Worst Rank)
    nuliftr is offline
    why would there be a limit?

    there is prob a more efficient way to do it though.
    Reply With Quote

  3. #3
    Dreamer Bulk PumkinPie's Avatar
    Join Date: May 2013
    Location: Florida, United States
    Posts: 3,693
    Rep Power: 34363
    PumkinPie has much to be proud of. One of the best! (+20000) PumkinPie has much to be proud of. One of the best! (+20000) PumkinPie has much to be proud of. One of the best! (+20000) PumkinPie has much to be proud of. One of the best! (+20000) PumkinPie has much to be proud of. One of the best! (+20000) PumkinPie has much to be proud of. One of the best! (+20000) PumkinPie has much to be proud of. One of the best! (+20000) PumkinPie has much to be proud of. One of the best! (+20000) PumkinPie has much to be proud of. One of the best! (+20000) PumkinPie has much to be proud of. One of the best! (+20000) PumkinPie has much to be proud of. One of the best! (+20000)
    PumkinPie is offline
    No limit. Look at the switch statement though if it works.
    http://www.zentut.com/c-tutorial/c-switch-case/
    libs gonna lib
    Reply With Quote

  4. #4
    Registered User SugarFree1's Avatar
    Join Date: Jun 2011
    Location: Douglassville, Pennsylvania, United States
    Posts: 4,340
    Rep Power: 11812
    SugarFree1 is a splendid one to behold. (+10000) SugarFree1 is a splendid one to behold. (+10000) SugarFree1 is a splendid one to behold. (+10000) SugarFree1 is a splendid one to behold. (+10000) SugarFree1 is a splendid one to behold. (+10000) SugarFree1 is a splendid one to behold. (+10000) SugarFree1 is a splendid one to behold. (+10000) SugarFree1 is a splendid one to behold. (+10000) SugarFree1 is a splendid one to behold. (+10000) SugarFree1 is a splendid one to behold. (+10000) SugarFree1 is a splendid one to behold. (+10000)
    SugarFree1 is offline
    There is no limit on nested If/Else statements; however there most likely is a more efficient way of programming the same.
    Disabled Combat Veteran (11B)
    My Home Gym Thread: http://forum.bodybuilding.com/showthread.php?t=160414931
    Reply With Quote

  5. #5
    Registered User AgentLemon's Avatar
    Join Date: Jul 2013
    Posts: 1,361
    Rep Power: 413
    AgentLemon has a spectacular aura about. (+250) AgentLemon has a spectacular aura about. (+250) AgentLemon has a spectacular aura about. (+250) AgentLemon has a spectacular aura about. (+250) AgentLemon has a spectacular aura about. (+250) AgentLemon has a spectacular aura about. (+250) AgentLemon has a spectacular aura about. (+250) AgentLemon has a spectacular aura about. (+250) AgentLemon has a spectacular aura about. (+250) AgentLemon has a spectacular aura about. (+250) AgentLemon has a spectacular aura about. (+250)
    AgentLemon is offline
    What are you trying to do that will take so many of them.. look at switch case. There is probably a much easier way to do it..
    Reply With Quote

  6. #6
    Protein Hacker mehdi84's Avatar
    Join Date: Dec 2007
    Location: Massachusetts, United States
    Posts: 9,556
    Rep Power: 6734
    mehdi84 is a name known to all. (+5000) mehdi84 is a name known to all. (+5000) mehdi84 is a name known to all. (+5000) mehdi84 is a name known to all. (+5000) mehdi84 is a name known to all. (+5000) mehdi84 is a name known to all. (+5000) mehdi84 is a name known to all. (+5000) mehdi84 is a name known to all. (+5000) mehdi84 is a name known to all. (+5000) mehdi84 is a name known to all. (+5000) mehdi84 is a name known to all. (+5000)
    mehdi84 is offline
    No, and that's not a nested if.
    Because if it were easy, I wouldn't be interested.
    Reply With Quote

  7. #7
    Registered User beanlet21's Avatar
    Join Date: Nov 2011
    Age: 31
    Posts: 1,384
    Rep Power: 0
    beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank)
    beanlet21 is offline
    Originally Posted by AgentLemon View Post
    What are you trying to do that will take so many of them.. look at switch case. There is probably a much easier way to do it..
    each "if" statement contains something that looks like x==1 && y==-1 && c==1 and i have 21 combinations i need to test.

    thanks for the answers.
    Reply With Quote

  8. #8
    Deeds, Not Words TallJJ's Avatar
    Join Date: Jan 2013
    Location: Netherlands
    Age: 30
    Posts: 7,956
    Rep Power: 3796
    TallJJ is a glorious beacon of knowledge. (+2500) TallJJ is a glorious beacon of knowledge. (+2500) TallJJ is a glorious beacon of knowledge. (+2500) TallJJ is a glorious beacon of knowledge. (+2500) TallJJ is a glorious beacon of knowledge. (+2500) TallJJ is a glorious beacon of knowledge. (+2500) TallJJ is a glorious beacon of knowledge. (+2500) TallJJ is a glorious beacon of knowledge. (+2500) TallJJ is a glorious beacon of knowledge. (+2500) TallJJ is a glorious beacon of knowledge. (+2500) TallJJ is a glorious beacon of knowledge. (+2500)
    TallJJ is offline
    Originally Posted by beanlet21 View Post
    each "if" statement contains something that looks like x==1 && y==-1 && c==1 and i have 21 combinations i need to test.

    thanks for the answers.
    Put those in an array and have a for loop check each value.. if you have 40 if/else statements you have a big chance there is a more efficient way.
    6'6" crew
    220 lbs in avi (srs)
    Computer Science crew
    Prenup if I ever get married crew
    Reply With Quote

  9. #9
    Registered User beanlet21's Avatar
    Join Date: Nov 2011
    Age: 31
    Posts: 1,384
    Rep Power: 0
    beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank)
    beanlet21 is offline
    Originally Posted by TallJJ View Post
    Put those in an array and have a for loop check each value.. if you have 40 if/else statements you have a big chance there is a more efficient way.
    the funny thing is that each number i am checking is already an element of an array. i couldnt think of a way to make a loop for it though, as long as it works though i am happy.
    Reply With Quote

  10. #10
    Banned xdestron's Avatar
    Join Date: Aug 2008
    Location: Illinois, United States
    Posts: 4,946
    Rep Power: 0
    xdestron is just really nice. (+1000) xdestron is just really nice. (+1000) xdestron is just really nice. (+1000) xdestron is just really nice. (+1000) xdestron is just really nice. (+1000) xdestron is just really nice. (+1000) xdestron is just really nice. (+1000) xdestron is just really nice. (+1000) xdestron is just really nice. (+1000) xdestron is just really nice. (+1000) xdestron is just really nice. (+1000)
    xdestron is offline
    Doesn't C have a switch statement?
    Reply With Quote

  11. #11
    Registered User beanlet21's Avatar
    Join Date: Nov 2011
    Age: 31
    Posts: 1,384
    Rep Power: 0
    beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank) beanlet21 is the lowest scum of the boards. (Worst Rank)
    beanlet21 is offline
    Originally Posted by xdestron View Post
    Doesn't C have a switch statement?
    that would have been helpful to know what that was beforehand, lol. I think I am done with my program though 900 lines later. all for a simple tic-tac-toe game with 3 ai levels.
    Reply With Quote

  12. #12
    Registered User xrcwrn's Avatar
    Join Date: Nov 2020
    Age: 54
    Posts: 1
    Rep Power: 0
    xrcwrn is on a distinguished road. (+10)
    xrcwrn is offline
    There is no limit.
    You can put any number of if else, nested if else, ladder if else.
    If else is used to select any one of given two condition.

    You can check here.
    ebhor.com/if-else-statement-in-c-programming

    If you have more number of options any want to select any one then use
    switch case
    You can check here
    ebhor.com/switch-statement-in-c-programming

    Keep Learning and keep coding
    Reply With Quote

Posting Permissions

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