can anyone please tell me what is wrong with this programme i wrote?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ungetuem
    New Member
    • Sep 2015
    • 2

    can anyone please tell me what is wrong with this programme i wrote?

    i just started learning C, but after i finished writing this programme, it wouldn't respond to the number that i had entered. can anyone please tell me what is going on? thx!
    Attached Files
  • Clearner321
    New Member
    • Sep 2015
    • 22

    #2
    It works for me. What exactly is the problem you are facing. Better initialize all the local variables i, num1, num2 to 0.

    Comment

    • ungetuem
      New Member
      • Sep 2015
      • 2

      #3
      I've been unable to enter any values once i started running the program, it happened to some of my other programs too.

      Comment

      • tjnapster555
        New Member
        • Oct 2015
        • 1

        #4
        you need to put your case in parenthesis
        case 1:
        {
        num1=....
        num2=.....
        printf.....
        }

        break;
        also try to initialize all int to zero
        like this
        i=num1=num2=0;

        Comment

        • donbock
          Recognized Expert Top Contributor
          • Mar 2008
          • 2427

          #5
          1. Catch and print the return value from scanf (at least for debugging purposes).
          2. Terminate your puts strings with newline ('\n'). This is helpful when stdio uses buffered I/O.
          3. Notice that if the number is even you fall out of main rather than loop back to enter a new value.

          Putting braces around the cases won't change anything.

          Comment

          Working...