Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

In the context of programming, what is the difference between postfix and prefix operators? Preferably with examples.

user-image
Question added by Mohamed Saleh Elsayed Saleh , Senior System Administrator / Database Administrator , Habitat
Date Posted: 2017/09/20

Postfix opreator =variable & operator.

Prefix opreator =operator & variable.

eg : a=42;

       b=a++;

postfix operator form is a++ i.e, b=a then a=a+1;

prefix operator form is ++a i.e, a=a+1 then b=a;

Sheeth Rahiman
by Sheeth Rahiman , System Administrator , Homestyle

Postfix - Use & Operate ( Ex : a++ )

Prefix - Operate & Use ( Ex : ++a )

For Example,

Assume a=1 and

if b=a++ then b=1

if b=++a then b=2         

Vibin M Valsalan
by Vibin M Valsalan , Executive , Aramex Emirates LLC

a=1;

b=a++;

c=++a;

 

value of b =1

value of c= 3

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.