The Solution
QwertManiac said:
u cant use getchar() w/o including its headerfile (conio.h i think, been a long time since C progging)
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.
QwertManiac said:
Printf statements that dont display a variable dont need a parameter for that i think.
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.
it seems that your installation for c is not properly done.
most probably your installation of C could be corrupted.
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.
scanf() needs variable addresses not their values.
p, n, and r are not pointers. They are simple variables.
So, to pass their addresses to scanf() you have to precede them with an ampersand '&' like &p, &n and &r.
Just modify the original scanf() statements as follows and the program would run fine:
scanf ("%f", &p) ;
scanf ("%f", &n) ;
scanf ("%f", &r) ;
@ 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.