[snippage]
Others have noted your immediate problem (that Printf and printf are
different symbols, at least on most C89 implementations). One
followup also noted that scanf's "%f" directive requires a pointer
to a "float" variable, and you have:
int a, b;
so:
scanf("%f", &a);
is wrong. You must either make a and b both "float" (which then
requires more changes) or use scanf's "%d" directive here.
There are several even-worse problems lurking, however:
- scanf() is *extremely* difficult to use correctly. The
best approach for most C programmers, in my opinion, is
never to use scanf() at all. Instead, use something to
read a line of input (such as fgets(), or Chuck Falconer's
ggets(), or any number of similar functions -- just not
plain gets()), then use sscanf() on the resulting buffer.
- In any case, scanf() (or sscanf(), after switching to a much
safer version) has a return value, which you *must* test
to see whether the scanf() actually did anything.
printf("Please, Enter second Number : \n");
scanf("%f", &b);
printf("Please, Select the menu (+, -, *, /, % .\n");
scanf("%c", &symbol);
Here is the worst problem of all. Even if you change the two
scanf()s to use "%d", and check that they both return 1, this last
scanf() will read the next available character from the input
stream. Because you will have pressed the ENTER or RETURN key to
enter a number, the "next available character" will almost certainly
be a newline ('\n') -- so this scanf() will return 1, but will set
the variable "symbol" to '\n'.
The reason is that scanf()'s "%c" directive does *not* skip leading
white space. The "%f" and "%d" directives (and a number of similar
other ones) mean:
- First, consume (skip over and "eat up") any and all white space
(characters for which isspace() returns true).
- Then, read and convert a number ("int" for %d, "float" for
%f, "double" for %lf, and so on).
- If the input at this point is not syntactically valid, stop
with a matching failure, so that the scanf call returns a
smaller number. (For instance, scanf() might return 0 if
the input stream yields " \n\t\t\v\foops".)
- If the conversion overflows, do anything you feel like doing,
possibly including aborting the program run ("you" means
"the implementation" here).
- Otherwise, all went well; store the converted number and
increase the return value (unless assignment is suppressed
with the "*" modifier).
Note that this does *not* consume trailing white-space.
Two directives -- the "%c" and "%[" directives -- omit the "consume
leading white space" sequence. This means they will "see" any
*trailing* white space left behind by any earlier directives.
Using scanf() is thus like planting various time bombs. If you
use fgets() (or similar) to read entire input lines, then apply
sscanf() to those lines, these "time bombs" have much more limited
potential action, because the input line gets handled separately,
putting the input characters into a buffer where you can inspect
them, modify them, discard them, or do whatever you like with them,
*before* letting the underlying scanf engine see them. Any characters
the scanf engine ignores are still there in your buffer, before
and after the call to scanf, and are no longer in the input stream.
[variable "loop" is initially zero here]
[various things where errors set "loop" to 1]
If you ever get an error, this sets the variable "loop" to 1, so
that the do-loop repeats. The repeated do-loop starts with the
variable "loop" set to 1, and nothing will ever set it to zero,
so if the do-loop repeats, it will never terminate.
The simplest fix is to move the initialization of the variable
"loop" to the top of the loop:
do {
loop = 0;
... various things that may do loop=1 ...
} while (loop);
although there are other solutions that some people might find
"better".