1. Hey Guest Did you know you can win an Honor 10 phone worth ₹33,000 and an additional ₹70,000 in paytm vouchers, just by replying to some threads and taking part in the discussions happening in the Honor Hub?

    What are you waiting for? Start commenting and start winning! Remember to read the instructions posted here.

    Dismiss Notice

program compiles but does'nt run

Discussion in 'Software Q&A' started by makarand, Mar 29, 2006.

Thread Status:
Not open for further replies.
  1. makarand

    makarand New Member

    Joined:
    Jul 12, 2005
    Messages:
    66
    Likes Received:
    0
    Trophy Points:
    0
    Hey guys help me
    I use XP and just made a program in C
    when i compile it it shows 0 erros and 0 warnings
    when i run the program the first line is displayed "Enter the amount:"
    when i do so an erro comes up showing a prolem has occured and we're sorry for the inconvinience
    help me
     
  2. Minimalistix

    Minimalistix I'm back!

    Joined:
    May 16, 2004
    Messages:
    65
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Mumbai, Maharashtra
    Mate, without the source code how are we supposed to find out the problem? After all it has to be a coding error... right?
     
  3. ::vicky::

    ::vicky:: New Member

    Joined:
    Feb 23, 2006
    Messages:
    306
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    0X4B7H
    ya first show the coding i think ur code is ok as u say that code gets compiled but it is a windows error
     
  4. sakumar79

    sakumar79 Active Member

    Joined:
    Nov 28, 2004
    Messages:
    2,441
    Likes Received:
    9
    Trophy Points:
    38
    Location:
    Madurai
    ^^ There are two types of errors in programming - compile errors and runtime errors. Compile errors are syntax errors that are caught during compilation of the program. .. The runtime errors are those that are caused by logical errors...
    Since your program compiled without problem, you prob. dont have compile errors. Runtime errors can be caused by invalid pointers, division by zero, infinite loops,etc... That seems to be what you have... So, we will need the code to identify what the problem is...

    Arun
     
  5. OP
    OP
    makarand

    makarand New Member

    Joined:
    Jul 12, 2005
    Messages:
    66
    Likes Received:
    0
    Trophy Points:
    0
    dear friends its justb a simple program of finding simple interest
     
  6. sakumar79

    sakumar79 Active Member

    Joined:
    Nov 28, 2004
    Messages:
    2,441
    Likes Received:
    9
    Trophy Points:
    38
    Location:
    Madurai
    ^^^ Post the code because the error most probably lies in the logic somewhere... Only if you post the code can we test and identify the problem...

    Arun
     
  7. Gaurav

    Gaurav Member

    Joined:
    Mar 25, 2004
    Messages:
    483
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Delhi/NCR
    most probably your installation of C could be corrupted.
     
  8. mayanksharma

    mayanksharma New Member

    Joined:
    Mar 30, 2006
    Messages:
    598
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    Noida/NCR
    it seems that your installation for c is not properly done.this thing usually occurs whenever there is corruption. You can also try program compatability mode though!
     
  9. OP
    OP
    makarand

    makarand New Member

    Joined:
    Jul 12, 2005
    Messages:
    66
    Likes Received:
    0
    Trophy Points:
    0
    #inlcude<stdio.h>
    int main()
    {
    float p,n,r,si;
    printf("Enter Principal:",p);
    scanf("%f",p);
    printf("Enter Years:",n);
    scanf("%f",n);
    printf("Enter Rate:",r);
    scanf("%f",r);
    si = p*n*r/100;
    printf("Simple Interest:%f",si);
    getchar();
    }
     
  10. QwertyManiac

    QwertyManiac Commander in Chief

    Joined:
    Jul 17, 2005
    Messages:
    6,656
    Likes Received:
    10
    Trophy Points:
    0
    1. u cant use getchar() w/o including its headerfile (conio.h i think, been a long time since C progging)
    2. Printf statements that dont display a variable dont need a parameter for that i think.
    Code:
    printf("Enter Principal:",p); is wrong, printf("Enter Principal:"); is just fine because u are using the scanf statement in the next line
     
  11. Minimalistix

    Minimalistix I'm back!

    Joined:
    May 16, 2004
    Messages:
    65
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Mumbai, Maharashtra
    The Solution

    Yes mate, it's been a long time since you left C programming 'coz the header file <conio.h> isn't needed for getchar(). It's needed for getch() which is what should have been used here.

    Correct! The 2nd parameters aren't needed here but they are not the source of the problem 'coz by nature printf() ignores any "extra" parameters passed to it beyond what's needed by the format string.

    Now, I don't know how they reached to this conclusion but not everything can be solved by going the "uninstall-then-re-install" way.

    So, what's the error? It's actually a very very very simple error and half of you are gonna knock on your heads when you'll know what it is.

    @ makarand :
    One more thing, to make your program wait for a keystroke at the end you need to use getch() with #include <conio.h>. getchar() won't work.
     
  12. anubhav_har

    anubhav_har New Member

    Joined:
    Aug 25, 2004
    Messages:
    387
    Likes Received:
    0
    Trophy Points:
    0
    You gotta put & with scanf
    scanf("%f",&p);
     
  13. mayanksharma

    mayanksharma New Member

    Joined:
    Mar 30, 2006
    Messages:
    598
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    Noida/NCR
    you have to provide the address pass medium to the variables defined.
    do it like this:-

    scanf("%f",&r);
    and make sure to return value to 0 in the end of the program,if you have included int before main.This will reduce your warnings....
     
  14. QwertyManiac

    QwertyManiac Commander in Chief

    Joined:
    Jul 17, 2005
    Messages:
    6,656
    Likes Received:
    10
    Trophy Points:
    0
    Oh, missed readin that part, sorry :oops: C, I guess I wil l have to start over again :lol:
     
  15. OP
    OP
    makarand

    makarand New Member

    Joined:
    Jul 12, 2005
    Messages:
    66
    Likes Received:
    0
    Trophy Points:
    0
    Thank You guys
     
Thread Status:
Not open for further replies.

Share This Page