what is unary operator?how to solve problem of unary operators.

my pic

lets check it out the ans of unary operators.

so first of all we know that unary operators is the one and first type of operators.

so lets look on the definition  and solve some problems on unary operator:–

So operators requires only one operands to perform its operation.

int x=2;

Unary operator are those which takes one  operant to perform its task.

1.unary plus(+) and minus(_).

2.increment (++)  and decrement (__).

3.size of operators.

there  are  two types of increment operators :-

1.preincrement  (++x)

2.postincrement (X++)

there are also two types of decrement.

  1. predecrement (–x).
  2. postdecrement(x__.

now we solve the problem.

here i am going to understand this topic by giving example that is quit short.

beacuse in this topic i am not focusing in syntax i am focusing to learn the fact learn the operators that it.

so here is your first example:–

void main()


int x=1;







output:  1


In the first print statement we put the same value of x that is one.

and in the next statement when we call the same variable on 2nd time then we will the or increment 1 in the value of x beacuse the increment  operators (++) is used when we call the same varible another time.

hope you will understand and you will like my ans .

so plz give comments .



Leave a Reply

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