Thread: need some debugging help

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    494

    need some debugging help

    Code:
    #include <stdio.h>
    main()
    {
        int num1;
        int sum=0;
        
    
        printf("enter a positive number: ");
        num1= getc(stdin);
            
        for (num1=0; num1<4; num1++)
    
        if (num1 == 1)
    
            printf("Message I, num1 is %d\n", num1);
    
        else sum=((num1-1) + 2*(num1-1));
    
            printf("Message II, sum is %d\n", sum);
            
        return 0;
    }
    someone help me with this if statement, for some reason when the number i enter is 1, the program should end there, right? instead it goes and computes the else part also.

    edit:nvm
    Last edited by InvariantLoop; 02-09-2005 at 06:36 PM.
    When no one helps you out. Call google();

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dev-C++: Problems with Breakpoint Debugging
    By Thileepan_Bala in forum C Programming
    Replies: 1
    Last Post: 01-17-2008, 10:48 AM
  2. Problem in debugging in Eclipse
    By Bargi in forum Linux Programming
    Replies: 1
    Last Post: 08-21-2007, 09:53 AM
  3. Debugging Dev C++
    By tuurb046 in forum Tech Board
    Replies: 10
    Last Post: 08-16-2007, 12:51 PM
  4. Debugging book recommendation
    By dagans in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 09-13-2005, 07:35 PM
  5. debugging directx apps
    By confuted in forum C++ Programming
    Replies: 1
    Last Post: 08-16-2003, 08:56 AM