Message after compilation to turn on debugger

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wissywise
    New Member
    • Sep 2007
    • 3

    Message after compilation to turn on debugger

    Hi all,

    I have written some codes in "C" but each time I tried to run the code after it has been compiled, I get a message telling me to turn the deburger on. I tried but no progress. An example the code below:
    [code=c]
    *Analysing exam results*/

    #include <stdio.h>

    int main()
    {
    int passes = 0; /*no. of passes*/
    int failures = 0; /* no. of failures*/
    int student = 1; /* student counter*/
    int result; /* one exam result*/
    /*counter-controlled loop to process 10 students*/
    while(student <= 10){
    printf("Enter result (1 = pass, 2 = fail): ");
    scanf("%d", &result);

    /*increment result*/
    if(result==1){
    passes = passes + 1;
    }
    else{
    failures = failures + 1;
    }
    /*increment student counter*/
    student = student + 1;
    }
    /*display no. of passes and failures*/
    printf("Passed %d\n", passes);
    printf("Failed %d\n", failures);
    /* more than eight students passed, print raise tuition fees*/
    if(passes > 8){
    printf("Raise Tuition Fees\n");
    }
    else{
    printf("Maintai n Current Fees\n");
    }
    return 0;
    }
    [/code]
    the code compiles alright but it is run nothing appears on the screen. not result. at time blank DOS appears. Can someone please assist me. Thanks

    wissywise
    Last edited by sicarie; Sep 18 '07, 01:04 PM. Reason: Code tags
  • drnrusu
    New Member
    • Sep 2007
    • 6

    #2
    I tried your code and it works perfect
    (I run it on a borlandc++ 3.1 on WinXp)
    Originally posted by wissywise
    Hi all,

    I have written some codes in "C" but each time I tried to run the code after it has been compiled, I get a message telling me to turn the deburger on. I tried but no progress. An example the code below:

    *Analysing exam results*/

    #include <stdio.h>

    int main()
    {
    int passes = 0; /*no. of passes*/
    int failures = 0; /* no. of failures*/
    int student = 1; /* student counter*/
    int result; /* one exam result*/
    /*counter-controlled loop to process 10 students*/
    while(student <= 10){
    printf("Enter result (1 = pass, 2 = fail): ");
    scanf("%d", &result);

    /*increment result*/
    if(result==1){
    passes = passes + 1;
    }
    else{
    failures = failures + 1;
    }
    /*increment student counter*/
    student = student + 1;
    }
    /*display no. of passes and failures*/
    printf("Passed %d\n", passes);
    printf("Failed %d\n", failures);
    /* more than eight students passed, print raise tuition fees*/
    if(passes > 8){
    printf("Raise Tuition Fees\n");
    }
    else{
    printf("Maintai n Current Fees\n");
    }
    return 0;
    }

    the code compiles alright but it is run nothing appears on the screen. not result. at time blank DOS appears. Can someone please assist me. Thanks

    wissywise

    Comment

    • wissywise
      New Member
      • Sep 2007
      • 3

      #3
      Originally posted by drnrusu
      I tried your code and it works perfect
      (I run it on a borlandc++ 3.1 on WinXp)
      Thanks very much for your reply. I think I need to download borlandc++3.1 and try it.

      Comment

      • sicarie
        Recognized Expert Specialist
        • Nov 2006
        • 4677

        #4
        Originally posted by wissywise
        Thanks very much for your reply. I think I need to download borlandc++3.1 and try it.
        I compiled and ran it in gcc as well, and it compiles and runs (though not entirely correctly - you have a logical error in how your 'fails' are calculated. I put in a 3 to error the program out and it counted as a 'fail'. Just FYI.).

        Comment

        Working...