Unary Arithmetic Operators In C Language

Dear Sciaku Learner you are not logged in or not enrolled in this course.

Please Click on login or enroll now button.

If you have any query feel free to chat us!

Happy Coding! Happy Learning!

In C programming, unary arithmetic operators are used to perform mathematical operations on a single operand (variable or constant). Here are the most common unary arithmetic operators used in C:

  • ++ : increment operator. It increases the value of the operand by 1.

Copy code

int x = 5; x++;

This will increment x by 1, resulting in x = 6.

  • -- : decrement operator. It decreases the value of the operand by 1.

Copy code

int y = 7; y--;

This will decrement y by 1, resulting in y = 6.

  • + : unary plus operator. It does not change the value of the operand.

Copy code

int z = +5;

This will not change the value of z, resulting in z = 5.

  • - : unary minus operator. It changes the sign of the operand (positive to negative or negative to positive).

Copy code

int a = -5;

This will change the sign of a to negative, resulting in a = -5.

It's important to note that unary operators have a higher precedence than binary operators in C. Also, it's important to be aware of the position of the operator, whether it's prefix or postfix, because it can change the value of the operand. In the examples above, I have used postfix increment and decrement (x++ and y--), but you can also use prefix increment and decrement (++x and --y) which will change the value of x or y before the expression is evaluated.

4. Operators

Comments: 0

Frequently Asked Questions (FAQs)

How do I register on Sciaku.com?
How can I enroll in a course on Sciaku.com?
Are there free courses available on Sciaku.com?
How do I purchase a paid course on Sciaku.com?
What payment methods are accepted on Sciaku.com?
How will I access the course content after purchasing a course?
How long do I have access to a purchased course on Sciaku.com?
How do I contact the admin for assistance or support?
Can I get a refund for a course I've purchased?
How does the admin grant access to a course after payment?