Ok, the code I posted above was a serious simplification of a larger program that I was doing.

I THOUGHT I had isolated the problem, and thats what the above was. Not the case

Sorry about that.

This is the actual program:

Code:

#include <stdio.h>
#define OVER_TEN_FINE 50
/*#define OVER_TWENTY_FINE 75*/
#define D_VIOLATIONS_OVER_3 20
main()
{
int fine = 5,
number_of_a,
number_of_b,
number_of_c,
number_of_d,
a_charge = 10,
b_charge = 20,
c_charge = 30,
d_charge = 50,
total_number_fines = 0,
total_number_of_A_fines = 0,
total_number_of_B_fines = 0,
total_number_of_C_fines = 0,
OVER_TWENTY_FINE = 75,
number_of_d_over_three,
USING_OVER_TWENTY_FINE = 0;
printf("\nPlease enter the number of A violations :");
scanf("%d" , &number_of_a);
total_number_fines += total_number_of_A_fines += number_of_a; /*accumulating the total # of fines and a fines*/
number_of_a *= a_charge; /* the number of times of violation multiplied by corresponding fine */
printf("\nPlease enter the number of B violations :");
scanf("%d" , &number_of_b);
total_number_fines += total_number_of_B_fines += number_of_b;
number_of_b *= b_charge;
printf("\nPlease enter the number of C violations :");
scanf("%d" , &number_of_c);
total_number_fines += total_number_of_C_fines += number_of_c;
number_of_c *= c_charge;
printf("\nPlease enter the number of D violations :");
scanf("%d" , &number_of_d);
total_number_fines += number_of_d;
if(total_number_of_A_fines > 10)
number_of_a += OVER_TEN_FINE;
if(total_number_of_B_fines > 10) /*<------- implementing the over 10 violations rule for*/
/*a, b, and c-------->*/
number_of_b += OVER_TEN_FINE;
if(total_number_of_C_fines > 10)
number_of_c += OVER_TEN_FINE;
if(total_number_fines > 20) /*----a,b, and c only!----*/
if( (number_of_a <= 10) && (number_of_b <= 10) && (number_of_c <= 10) )
{
USING_OVER_TWENTY_FINE = OVER_TWENTY_FINE;
/*printf("\nusing over twenty fine is %d." , USING_OVER_TWENTY_FINE);*/ /*to check for assignment*/
}
if(number_of_d > 3)
{
number_of_d_over_three = number_of_d - 3;
number_of_d = (3 * d_charge) + (number_of_d_over_three *= D_VIOLATIONS_OVER_3);
}
else
number_of_d *= d_charge;
printf("\nusing over twenty fine is %d." , USING_OVER_TWENTY_FINE);/*to check for assignment*/
printf("\nnumber of d is %d." , number_of_d);
printf("\nThe total fine for the person is %d." , USING_OVER_TWENTY_FINE + number_of_a + number_of_b + number_of_c + number_of_d);
printf("\nThe total number of fines is %d." , total_number_fines);
}

So heres the thing. The nested "if" statement that starts with - if(total_number_fines > 20).

You see that it says : if total number of fines is > than 20: and

if number of a, b and c are <= to 10: then

assign the value of OVER_TWENTY_FINE to

USING_OVER_TWENTY_FINE.

(the following printf is just to check to see if it made it)

Well, the thing is it NEVER makes the assignment no matter what I do. I tested every other branch of the program and everything else works expectedly. But for some reason, USING_OVER_TWENTY_FINE wont take any value. I placed printf statements here and there to trace it and it never takes on a value. Regardless of whether OVER_TWENTY_FINE is a #define statement, or as an integer. So the rest of that nested if doesn't execute. I placed another printf statement down in the output to test the value of USING_OVER_TWENTY_FINE, still nothing.

Thats the problem.