c program of Prefix / Postfix operator


PreFix  ++,– and PostFix ++, — is unary operator in c which increment ++ or decrement  — only one value. The main point is ++ apply before an operand it get updated new  value or if apply after an operand it get old without updated value.

example :

int a=2,b;

b=++a so  b get 3

b=a++ so b get 2


write a c example program for unary operator for increment ++ and decrement —

 solution of c example program

output of 

a = 5           a = 5

a = 6           a = 7


unary prefix ++a,–a  and postfix a++ ,a– one value add-substract and most important it works ..

start from right to left association 

 int x = a++ * ++a – a++;             left <– right  

 

Find output of  int x = a++ * ++a – a++;


solution of c example program

output  int  x = a++ * ++a – a++;

x = 7           a = 5

 

(Visited 54 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *


CAPTCHA Image
Reload Image