Search code examples
cassignment-operator

Implementation of Assignment operator


Can i write assignment operator in a cascaded manner.Following are two statements how can i write them

 total_marks/=1000;
 total_marks*=100;

Can we do something like but where we place 100

total_marks*=total_marks/=1000;     

Solution

  • In C++ you could write for example

    ( total_marks/=1000 ) *= 100;
    

    However in C this code will not compile.

    In C ( and C++ ) you could write the following way using the comma operator

    total_marks/=1000, total_marks *= 100;
    

    I mean if you need this in expressions.