Why 6/5 gives 1 not 1.2 in C program?

Why  6/5 gives  1 not 1.2 in C program?

Do you know, if we calculate 6/5 gives 1 not 1.2 in C

Similarly, 4/8 gives 1 not 0.5

Do you know why? Because both values are integers then C evaluate result also int not float but when one value is int and another value is float then it evaluates result also as float, so  6.5/5.5 gives 1.1818 which is obvious.

Every operator in c has

  • Priority
  • Associativity

What is an operator?

Declaration gives the list of variables with a different type of values to be used, the operator is something which tells what to be done to the declared variables.

Precedence and order of evaluation table


Hi, i am Mohammed Anees

Leave a Reply

Your email address will not be published.