• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Caleb Curry

Making Money and Investing

  • Home
  • Make Money Online
  • How to Buy Bitcoin
  • Get Started with Real Estate Investing
  • How to Start a Website
  • Courses
    • Full Time Income Online
  • Sponsorship

C Programming Tutorial 33 – Unary Plus and Minus

October 18, 2018 by Caleb Curry Leave a Comment

Did you read the last blog on Modulus Operators? Are you new here? Start at the beginning, Intro to C!

This video is going to be talking about the minus and plus operator.  But wait, don’t leave yet. We’re not talking about the binary minus and plus operators, rather the unary ones.  As a reminder, the difference is how many operands they work on. The binary minus operator, for example, will take one operand, subtract the second operand from it, and generate a result from that.  Neither of the operands are modified.

The unary minus, on the other hand, just takes one operand, and negates it.  To negate something means to take the negative of.  To make this clear, let’s go through an example.

double money = 25;

double bill = 15;

double total = money – bill;

This example uses the binary operator.  But now let’s say you go to pay your bill and they say, you know what, we are going to give you some money instead:

double total = money – -bill;

Now, we essentially have 25 – -15, which becomes 40.

Now, what is the value of bill?

The value of bill is still 15.  This operator does not change the value.  In the next video we are going to talk about a unary operator that actually does change the operands value.

There is also a unary plus, which is less useful, so I’m not really going to talk about it.  I would encourage you if you are an eager learner to look up the use of the unary plus operator.

In the next blog we are going to be discussing all of the Increment and Decrement Operators. Check it out!

Filed Under: Uncategorized Tagged With: c programming, unary plus and minus

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

my face to show my face

My name is Caleb Curry and I started my online business teaching software development and doing digital marketing for brands. Entrepreneurship has changed my life and has allowed me to earn a full time living from anywhere. I now have the freedom and energy to pursue skills and opportunities that I find interesting. This website is all about my journey.

Get my top Python Tips and Tricks

50+ Python Tips and Tricks!

Subscribe to our newsletter to get notes and latest content by email.

    We won't send you spam. Unsubscribe at any time.

    Follow Me!

    • Instagram
    • YouTube

    Recent Posts

    Copyright © 2021 · Genesis Sample on Genesis Framework · WordPress · Log in