what is an operator in C

what is an operator in c?

Hey there, Do you know? What is an operator in c? If not, then let me explain you the concept of an operator in c with operator priority and 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.

Every operator in c has

  • Priority
  • Associativity

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.

Still confused! Have you ever checked the arthimatic in c, if not, then check now

#include <stdio.h>

int main()


    int k;



    return 0;


Arithmetic in c        result                                 

K=12/18                      0                                      

K=20/42                      0   

K=72/20                      3 

K=88/48                      1   

K=44/66                     0  

K=88/25                    3    

K=66/30                     2    

normal Arithmetic    result

K=12/18                      0.666                                     

K=20/42                      0.4761  

K=72/20                      3.6

K=88/48                      1.833   

K=44/66                     0.666  

K=88/25                    3.52    

K=66/30                     2.2  

Observe the results carefully you will notice, arithmetic in C is different than the normal arithmetic because when both values are integers then C evaluate result as int not float

So, when ever you do any arithmetic operation in C some problems may crop up.     

 Precedence and order of evaluation table

Check out some recent blog post

Mohammed Anees

Hey there, welcome to aneescraftsmanship I’m Mohammed Anees an independent developer/blogger.

Leave a Reply

Your email address will not be published.