Can't find the proper output in this code

Multi tool use
Multi tool use








up vote
-2
down vote

favorite












I was asked to write a program about a traveling man.
The direction of the program:




  1. Suppose a man (say, A) stands at (0, 0) and waits for the user to give him the direction and distance to go.


  2. The user may enter N E W S for north, east, west, south, and any value for the distance.


  3. When the user enters 0 as direction, stop and print out the location where the man stopped


My Code:



#include <stdio.h>

int main()
float x=0,y=0;
char dir;
float mile;

while(1)

printf("Enter input direction as N,S,E,W (0 to exit): ");
scanf("%c",&dir);

if(dir == '0')
break;
if(dir != 'N' && dir != 'S' && dir != 'E' && dir != 'W')

printf("Invalid Direction, re-enter n");
continue;


printf("Input mile in %c dir: ",dir);
scanf("%f",&mile);
if(dir == 'N')
y+=mile;

else if(dir == 'S')
y-=mile;

else if(dir == 'E')
x+=mile;

else if(dir == 'W')
x-=mile;


printf("nCurrent position of A: (%4.2f,%4.2f)n",x,y);
return 0;



But when I run the program after the first two inputs, it prints invalid outputs in the valid inputs.



output: enter image description here










share|improve this question























  • Show the output (edit the question)
    – Michael Butscher
    Nov 10 at 13:38






  • 1




    Don't post an image of text output. Also, if that is your current output: that is different code than the one in your question.
    – usr2564301
    Nov 10 at 13:40










  • @singlepiece .. Its a classic mistake of OR vs AND. It should be if(dir != 'N' && dir != 'S' && dir != 'E' && dir != 'W') . For eg if a user inputs 'N', in that case the if statement will still return success because its != 'S'..
    – pOrinG
    Nov 10 at 13:41











  • I missed the last line. But the code is not working.
    – singlepiece000
    Nov 10 at 13:43










  • Add a space before your scanf format strings. You are processing the blank Return.
    – usr2564301
    Nov 10 at 13:51














up vote
-2
down vote

favorite












I was asked to write a program about a traveling man.
The direction of the program:




  1. Suppose a man (say, A) stands at (0, 0) and waits for the user to give him the direction and distance to go.


  2. The user may enter N E W S for north, east, west, south, and any value for the distance.


  3. When the user enters 0 as direction, stop and print out the location where the man stopped


My Code:



#include <stdio.h>

int main()
float x=0,y=0;
char dir;
float mile;

while(1)

printf("Enter input direction as N,S,E,W (0 to exit): ");
scanf("%c",&dir);

if(dir == '0')
break;
if(dir != 'N' && dir != 'S' && dir != 'E' && dir != 'W')

printf("Invalid Direction, re-enter n");
continue;


printf("Input mile in %c dir: ",dir);
scanf("%f",&mile);
if(dir == 'N')
y+=mile;

else if(dir == 'S')
y-=mile;

else if(dir == 'E')
x+=mile;

else if(dir == 'W')
x-=mile;


printf("nCurrent position of A: (%4.2f,%4.2f)n",x,y);
return 0;



But when I run the program after the first two inputs, it prints invalid outputs in the valid inputs.



output: enter image description here










share|improve this question























  • Show the output (edit the question)
    – Michael Butscher
    Nov 10 at 13:38






  • 1




    Don't post an image of text output. Also, if that is your current output: that is different code than the one in your question.
    – usr2564301
    Nov 10 at 13:40










  • @singlepiece .. Its a classic mistake of OR vs AND. It should be if(dir != 'N' && dir != 'S' && dir != 'E' && dir != 'W') . For eg if a user inputs 'N', in that case the if statement will still return success because its != 'S'..
    – pOrinG
    Nov 10 at 13:41











  • I missed the last line. But the code is not working.
    – singlepiece000
    Nov 10 at 13:43










  • Add a space before your scanf format strings. You are processing the blank Return.
    – usr2564301
    Nov 10 at 13:51












up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











I was asked to write a program about a traveling man.
The direction of the program:




  1. Suppose a man (say, A) stands at (0, 0) and waits for the user to give him the direction and distance to go.


  2. The user may enter N E W S for north, east, west, south, and any value for the distance.


  3. When the user enters 0 as direction, stop and print out the location where the man stopped


My Code:



#include <stdio.h>

int main()
float x=0,y=0;
char dir;
float mile;

while(1)

printf("Enter input direction as N,S,E,W (0 to exit): ");
scanf("%c",&dir);

if(dir == '0')
break;
if(dir != 'N' && dir != 'S' && dir != 'E' && dir != 'W')

printf("Invalid Direction, re-enter n");
continue;


printf("Input mile in %c dir: ",dir);
scanf("%f",&mile);
if(dir == 'N')
y+=mile;

else if(dir == 'S')
y-=mile;

else if(dir == 'E')
x+=mile;

else if(dir == 'W')
x-=mile;


printf("nCurrent position of A: (%4.2f,%4.2f)n",x,y);
return 0;



But when I run the program after the first two inputs, it prints invalid outputs in the valid inputs.



output: enter image description here










share|improve this question















I was asked to write a program about a traveling man.
The direction of the program:




  1. Suppose a man (say, A) stands at (0, 0) and waits for the user to give him the direction and distance to go.


  2. The user may enter N E W S for north, east, west, south, and any value for the distance.


  3. When the user enters 0 as direction, stop and print out the location where the man stopped


My Code:



#include <stdio.h>

int main()
float x=0,y=0;
char dir;
float mile;

while(1)

printf("Enter input direction as N,S,E,W (0 to exit): ");
scanf("%c",&dir);

if(dir == '0')
break;
if(dir != 'N' && dir != 'S' && dir != 'E' && dir != 'W')

printf("Invalid Direction, re-enter n");
continue;


printf("Input mile in %c dir: ",dir);
scanf("%f",&mile);
if(dir == 'N')
y+=mile;

else if(dir == 'S')
y-=mile;

else if(dir == 'E')
x+=mile;

else if(dir == 'W')
x-=mile;


printf("nCurrent position of A: (%4.2f,%4.2f)n",x,y);
return 0;



But when I run the program after the first two inputs, it prints invalid outputs in the valid inputs.



output: enter image description here







c loops if-statement scanf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 13:51









melpomene

55.6k54387




55.6k54387










asked Nov 10 at 13:35









singlepiece000

125




125











  • Show the output (edit the question)
    – Michael Butscher
    Nov 10 at 13:38






  • 1




    Don't post an image of text output. Also, if that is your current output: that is different code than the one in your question.
    – usr2564301
    Nov 10 at 13:40










  • @singlepiece .. Its a classic mistake of OR vs AND. It should be if(dir != 'N' && dir != 'S' && dir != 'E' && dir != 'W') . For eg if a user inputs 'N', in that case the if statement will still return success because its != 'S'..
    – pOrinG
    Nov 10 at 13:41











  • I missed the last line. But the code is not working.
    – singlepiece000
    Nov 10 at 13:43










  • Add a space before your scanf format strings. You are processing the blank Return.
    – usr2564301
    Nov 10 at 13:51
















  • Show the output (edit the question)
    – Michael Butscher
    Nov 10 at 13:38






  • 1




    Don't post an image of text output. Also, if that is your current output: that is different code than the one in your question.
    – usr2564301
    Nov 10 at 13:40










  • @singlepiece .. Its a classic mistake of OR vs AND. It should be if(dir != 'N' && dir != 'S' && dir != 'E' && dir != 'W') . For eg if a user inputs 'N', in that case the if statement will still return success because its != 'S'..
    – pOrinG
    Nov 10 at 13:41











  • I missed the last line. But the code is not working.
    – singlepiece000
    Nov 10 at 13:43










  • Add a space before your scanf format strings. You are processing the blank Return.
    – usr2564301
    Nov 10 at 13:51















Show the output (edit the question)
– Michael Butscher
Nov 10 at 13:38




Show the output (edit the question)
– Michael Butscher
Nov 10 at 13:38




1




1




Don't post an image of text output. Also, if that is your current output: that is different code than the one in your question.
– usr2564301
Nov 10 at 13:40




Don't post an image of text output. Also, if that is your current output: that is different code than the one in your question.
– usr2564301
Nov 10 at 13:40












@singlepiece .. Its a classic mistake of OR vs AND. It should be if(dir != 'N' && dir != 'S' && dir != 'E' && dir != 'W') . For eg if a user inputs 'N', in that case the if statement will still return success because its != 'S'..
– pOrinG
Nov 10 at 13:41





@singlepiece .. Its a classic mistake of OR vs AND. It should be if(dir != 'N' && dir != 'S' && dir != 'E' && dir != 'W') . For eg if a user inputs 'N', in that case the if statement will still return success because its != 'S'..
– pOrinG
Nov 10 at 13:41













I missed the last line. But the code is not working.
– singlepiece000
Nov 10 at 13:43




I missed the last line. But the code is not working.
– singlepiece000
Nov 10 at 13:43












Add a space before your scanf format strings. You are processing the blank Return.
– usr2564301
Nov 10 at 13:51




Add a space before your scanf format strings. You are processing the blank Return.
– usr2564301
Nov 10 at 13:51












2 Answers
2






active

oldest

votes

















up vote
0
down vote



accepted










So, I found your problem: When you were pressing "Enter" after you entered the "miles", that "Enter" got registered as input, as a 'n' character. I have a solution here for you, but if you don't prefer it, just make a special case in which you ignore the 'n' character. Something like else if (dir == 'n') continue;. I suspected this might be the problem but I confirmed it once I printed that "invalid character".



int main() 


float x = 0, y = 0;
char dir;
float mile;

do


printf("Enter input direction as N,S,E,W (0 to exit): ");
scanf("%c", &dir);

switch (dir)


case 'N':
printf("Input mile in %c dir: ", dir);
scanf("%f", &mile);
y += mile;
break;
case 'S':
printf("Input mile in %c dir: ", dir);
scanf("%f", &mile);
y -= mile;
break;
case 'E':
printf("Input mile in %c dir: ", dir);
scanf("%f", &mile);
x += mile;
break;
case 'W':
printf("Input mile in %c dir: ", dir);
scanf("%f", &mile);
x -= mile;
break;
case 'n':
break;
case '0':
break;
default:
printf("Invalid Direction, re-enter; You entered: %c n", dir);
break;


while (dir != '0');

printf("nCurrent position of A: (%4.2f, %4.2f)n", x, y);

return 0;






share|improve this answer








New contributor




Rakirnd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    up vote
    0
    down vote













    Its a classic mistake of OR vs AND.
    It should be



    if(dir != 'N' && dir != 'S' && dir != 'E' && dir != 'W') . 


    For eg if a user inputs 'N', in that case the if statement will still return success because its != 'S' and the if condition has a OR.



    Edit: (Following @usr2564301 's advice.)



    Add a space before scanf input %c.



    scanf(" %c",&dir);


    Check link for more explanation.






    share|improve this answer






















    • I code is just like you said.
      – singlepiece000
      Nov 10 at 13:45










    • Hmm.. You just edited your post to remove || and added && ... Now I look like a fool.. lol
      – pOrinG
      Nov 10 at 13:46










    • The revisions show it has been that all the time. But you could remove that from your answer so only my advice remains.
      – usr2564301
      Nov 10 at 14:06







    • 1




      @usr2564301 God yeah!! Anyway when he put the question, I had copied his source code into my editor to check. There was an OR in it.. I even double checked before commenting on the post and then later answering it ..
      – pOrinG
      Nov 10 at 14:09










    • @singlepiece000 Kindly do let me know if I am delusional. You started with a code which had || (OR) operator in if condition instead of && (AND) right ?
      – pOrinG
      Nov 10 at 14:11










    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239507%2fcant-find-the-proper-output-in-this-code%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    So, I found your problem: When you were pressing "Enter" after you entered the "miles", that "Enter" got registered as input, as a 'n' character. I have a solution here for you, but if you don't prefer it, just make a special case in which you ignore the 'n' character. Something like else if (dir == 'n') continue;. I suspected this might be the problem but I confirmed it once I printed that "invalid character".



    int main() 


    float x = 0, y = 0;
    char dir;
    float mile;

    do


    printf("Enter input direction as N,S,E,W (0 to exit): ");
    scanf("%c", &dir);

    switch (dir)


    case 'N':
    printf("Input mile in %c dir: ", dir);
    scanf("%f", &mile);
    y += mile;
    break;
    case 'S':
    printf("Input mile in %c dir: ", dir);
    scanf("%f", &mile);
    y -= mile;
    break;
    case 'E':
    printf("Input mile in %c dir: ", dir);
    scanf("%f", &mile);
    x += mile;
    break;
    case 'W':
    printf("Input mile in %c dir: ", dir);
    scanf("%f", &mile);
    x -= mile;
    break;
    case 'n':
    break;
    case '0':
    break;
    default:
    printf("Invalid Direction, re-enter; You entered: %c n", dir);
    break;


    while (dir != '0');

    printf("nCurrent position of A: (%4.2f, %4.2f)n", x, y);

    return 0;






    share|improve this answer








    New contributor




    Rakirnd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      0
      down vote



      accepted










      So, I found your problem: When you were pressing "Enter" after you entered the "miles", that "Enter" got registered as input, as a 'n' character. I have a solution here for you, but if you don't prefer it, just make a special case in which you ignore the 'n' character. Something like else if (dir == 'n') continue;. I suspected this might be the problem but I confirmed it once I printed that "invalid character".



      int main() 


      float x = 0, y = 0;
      char dir;
      float mile;

      do


      printf("Enter input direction as N,S,E,W (0 to exit): ");
      scanf("%c", &dir);

      switch (dir)


      case 'N':
      printf("Input mile in %c dir: ", dir);
      scanf("%f", &mile);
      y += mile;
      break;
      case 'S':
      printf("Input mile in %c dir: ", dir);
      scanf("%f", &mile);
      y -= mile;
      break;
      case 'E':
      printf("Input mile in %c dir: ", dir);
      scanf("%f", &mile);
      x += mile;
      break;
      case 'W':
      printf("Input mile in %c dir: ", dir);
      scanf("%f", &mile);
      x -= mile;
      break;
      case 'n':
      break;
      case '0':
      break;
      default:
      printf("Invalid Direction, re-enter; You entered: %c n", dir);
      break;


      while (dir != '0');

      printf("nCurrent position of A: (%4.2f, %4.2f)n", x, y);

      return 0;






      share|improve this answer








      New contributor




      Rakirnd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.



















        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        So, I found your problem: When you were pressing "Enter" after you entered the "miles", that "Enter" got registered as input, as a 'n' character. I have a solution here for you, but if you don't prefer it, just make a special case in which you ignore the 'n' character. Something like else if (dir == 'n') continue;. I suspected this might be the problem but I confirmed it once I printed that "invalid character".



        int main() 


        float x = 0, y = 0;
        char dir;
        float mile;

        do


        printf("Enter input direction as N,S,E,W (0 to exit): ");
        scanf("%c", &dir);

        switch (dir)


        case 'N':
        printf("Input mile in %c dir: ", dir);
        scanf("%f", &mile);
        y += mile;
        break;
        case 'S':
        printf("Input mile in %c dir: ", dir);
        scanf("%f", &mile);
        y -= mile;
        break;
        case 'E':
        printf("Input mile in %c dir: ", dir);
        scanf("%f", &mile);
        x += mile;
        break;
        case 'W':
        printf("Input mile in %c dir: ", dir);
        scanf("%f", &mile);
        x -= mile;
        break;
        case 'n':
        break;
        case '0':
        break;
        default:
        printf("Invalid Direction, re-enter; You entered: %c n", dir);
        break;


        while (dir != '0');

        printf("nCurrent position of A: (%4.2f, %4.2f)n", x, y);

        return 0;






        share|improve this answer








        New contributor




        Rakirnd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        So, I found your problem: When you were pressing "Enter" after you entered the "miles", that "Enter" got registered as input, as a 'n' character. I have a solution here for you, but if you don't prefer it, just make a special case in which you ignore the 'n' character. Something like else if (dir == 'n') continue;. I suspected this might be the problem but I confirmed it once I printed that "invalid character".



        int main() 


        float x = 0, y = 0;
        char dir;
        float mile;

        do


        printf("Enter input direction as N,S,E,W (0 to exit): ");
        scanf("%c", &dir);

        switch (dir)


        case 'N':
        printf("Input mile in %c dir: ", dir);
        scanf("%f", &mile);
        y += mile;
        break;
        case 'S':
        printf("Input mile in %c dir: ", dir);
        scanf("%f", &mile);
        y -= mile;
        break;
        case 'E':
        printf("Input mile in %c dir: ", dir);
        scanf("%f", &mile);
        x += mile;
        break;
        case 'W':
        printf("Input mile in %c dir: ", dir);
        scanf("%f", &mile);
        x -= mile;
        break;
        case 'n':
        break;
        case '0':
        break;
        default:
        printf("Invalid Direction, re-enter; You entered: %c n", dir);
        break;


        while (dir != '0');

        printf("nCurrent position of A: (%4.2f, %4.2f)n", x, y);

        return 0;







        share|improve this answer








        New contributor




        Rakirnd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        Rakirnd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered Nov 10 at 14:09









        Rakirnd

        713




        713




        New contributor




        Rakirnd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Rakirnd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Rakirnd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






















            up vote
            0
            down vote













            Its a classic mistake of OR vs AND.
            It should be



            if(dir != 'N' && dir != 'S' && dir != 'E' && dir != 'W') . 


            For eg if a user inputs 'N', in that case the if statement will still return success because its != 'S' and the if condition has a OR.



            Edit: (Following @usr2564301 's advice.)



            Add a space before scanf input %c.



            scanf(" %c",&dir);


            Check link for more explanation.






            share|improve this answer






















            • I code is just like you said.
              – singlepiece000
              Nov 10 at 13:45










            • Hmm.. You just edited your post to remove || and added && ... Now I look like a fool.. lol
              – pOrinG
              Nov 10 at 13:46










            • The revisions show it has been that all the time. But you could remove that from your answer so only my advice remains.
              – usr2564301
              Nov 10 at 14:06







            • 1




              @usr2564301 God yeah!! Anyway when he put the question, I had copied his source code into my editor to check. There was an OR in it.. I even double checked before commenting on the post and then later answering it ..
              – pOrinG
              Nov 10 at 14:09










            • @singlepiece000 Kindly do let me know if I am delusional. You started with a code which had || (OR) operator in if condition instead of && (AND) right ?
              – pOrinG
              Nov 10 at 14:11














            up vote
            0
            down vote













            Its a classic mistake of OR vs AND.
            It should be



            if(dir != 'N' && dir != 'S' && dir != 'E' && dir != 'W') . 


            For eg if a user inputs 'N', in that case the if statement will still return success because its != 'S' and the if condition has a OR.



            Edit: (Following @usr2564301 's advice.)



            Add a space before scanf input %c.



            scanf(" %c",&dir);


            Check link for more explanation.






            share|improve this answer






















            • I code is just like you said.
              – singlepiece000
              Nov 10 at 13:45










            • Hmm.. You just edited your post to remove || and added && ... Now I look like a fool.. lol
              – pOrinG
              Nov 10 at 13:46










            • The revisions show it has been that all the time. But you could remove that from your answer so only my advice remains.
              – usr2564301
              Nov 10 at 14:06







            • 1




              @usr2564301 God yeah!! Anyway when he put the question, I had copied his source code into my editor to check. There was an OR in it.. I even double checked before commenting on the post and then later answering it ..
              – pOrinG
              Nov 10 at 14:09










            • @singlepiece000 Kindly do let me know if I am delusional. You started with a code which had || (OR) operator in if condition instead of && (AND) right ?
              – pOrinG
              Nov 10 at 14:11












            up vote
            0
            down vote










            up vote
            0
            down vote









            Its a classic mistake of OR vs AND.
            It should be



            if(dir != 'N' && dir != 'S' && dir != 'E' && dir != 'W') . 


            For eg if a user inputs 'N', in that case the if statement will still return success because its != 'S' and the if condition has a OR.



            Edit: (Following @usr2564301 's advice.)



            Add a space before scanf input %c.



            scanf(" %c",&dir);


            Check link for more explanation.






            share|improve this answer














            Its a classic mistake of OR vs AND.
            It should be



            if(dir != 'N' && dir != 'S' && dir != 'E' && dir != 'W') . 


            For eg if a user inputs 'N', in that case the if statement will still return success because its != 'S' and the if condition has a OR.



            Edit: (Following @usr2564301 's advice.)



            Add a space before scanf input %c.



            scanf(" %c",&dir);


            Check link for more explanation.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 10 at 14:19

























            answered Nov 10 at 13:43









            pOrinG

            505316




            505316











            • I code is just like you said.
              – singlepiece000
              Nov 10 at 13:45










            • Hmm.. You just edited your post to remove || and added && ... Now I look like a fool.. lol
              – pOrinG
              Nov 10 at 13:46










            • The revisions show it has been that all the time. But you could remove that from your answer so only my advice remains.
              – usr2564301
              Nov 10 at 14:06







            • 1




              @usr2564301 God yeah!! Anyway when he put the question, I had copied his source code into my editor to check. There was an OR in it.. I even double checked before commenting on the post and then later answering it ..
              – pOrinG
              Nov 10 at 14:09










            • @singlepiece000 Kindly do let me know if I am delusional. You started with a code which had || (OR) operator in if condition instead of && (AND) right ?
              – pOrinG
              Nov 10 at 14:11
















            • I code is just like you said.
              – singlepiece000
              Nov 10 at 13:45










            • Hmm.. You just edited your post to remove || and added && ... Now I look like a fool.. lol
              – pOrinG
              Nov 10 at 13:46










            • The revisions show it has been that all the time. But you could remove that from your answer so only my advice remains.
              – usr2564301
              Nov 10 at 14:06







            • 1




              @usr2564301 God yeah!! Anyway when he put the question, I had copied his source code into my editor to check. There was an OR in it.. I even double checked before commenting on the post and then later answering it ..
              – pOrinG
              Nov 10 at 14:09










            • @singlepiece000 Kindly do let me know if I am delusional. You started with a code which had || (OR) operator in if condition instead of && (AND) right ?
              – pOrinG
              Nov 10 at 14:11















            I code is just like you said.
            – singlepiece000
            Nov 10 at 13:45




            I code is just like you said.
            – singlepiece000
            Nov 10 at 13:45












            Hmm.. You just edited your post to remove || and added && ... Now I look like a fool.. lol
            – pOrinG
            Nov 10 at 13:46




            Hmm.. You just edited your post to remove || and added && ... Now I look like a fool.. lol
            – pOrinG
            Nov 10 at 13:46












            The revisions show it has been that all the time. But you could remove that from your answer so only my advice remains.
            – usr2564301
            Nov 10 at 14:06





            The revisions show it has been that all the time. But you could remove that from your answer so only my advice remains.
            – usr2564301
            Nov 10 at 14:06





            1




            1




            @usr2564301 God yeah!! Anyway when he put the question, I had copied his source code into my editor to check. There was an OR in it.. I even double checked before commenting on the post and then later answering it ..
            – pOrinG
            Nov 10 at 14:09




            @usr2564301 God yeah!! Anyway when he put the question, I had copied his source code into my editor to check. There was an OR in it.. I even double checked before commenting on the post and then later answering it ..
            – pOrinG
            Nov 10 at 14:09












            @singlepiece000 Kindly do let me know if I am delusional. You started with a code which had || (OR) operator in if condition instead of && (AND) right ?
            – pOrinG
            Nov 10 at 14:11




            @singlepiece000 Kindly do let me know if I am delusional. You started with a code which had || (OR) operator in if condition instead of && (AND) right ?
            – pOrinG
            Nov 10 at 14:11

















             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239507%2fcant-find-the-proper-output-in-this-code%23new-answer', 'question_page');

            );

            Post as a guest














































































            hWBshg J7hXUINoqLm,Y1fA gi,iZU3bmy2SNU,eU KrYXFDsM
            iagZJg ojODHN7047975xrhGJ0sW9 LAd2Fa4k HV5LNS XkshKH JdP3DeH3WHfQ20M6,fQQBF0x6p

            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            Can't figure out why I get Error loading static resource from app.xaml

            How to fill missing numeric if any value in a subset is missing, all other columns with the same subset are missing