Lets take M. You do use it on lines 58, 61, 64, and 67.
When you do reach line 58, have you set the value of M to be something?
You might set the value on lines 40, 43, and/or 46. None of those is executed, if a==b && b==c, but the compiler does not see like we do that the whole branch is skipped if that is true.
The compiler has both "errors" and "warnings".
It is good to pay attention to them all.
You can initialize variables with known values and modify your conditions. Both will remove the warning. The important thing is to check that your logic is sound.
You had
//M=max(a,max(b,c));
. You could mimic that:
1 2 3 4 5
|
if ( b < c ) M=c;
else M=b;
// M is now max(b,c)
if ( M < a ) M = a;
|
Or, the common "find largest" logic:
1 2 3
|
int M = a;
if ( M < b ) M = b;
if ( M < c ) M = c;
|
You don't have to declare the M, etc already on line 8. It is enough to declate them within lines 38-67, where they are needed.