Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Assignment, Comparison, Not Equal To | Operators
C Basics

Assignment, Comparison, Not Equal To

We've learned how to store data in variables, organize data into arrays, and display data as strings. Yet, we haven't explored how to modify or manipulate that data.

Assignment Operator (=)

We're already familiar with this operator. It assigns the value on the right to the variable on the left:

Comparison Operators (!=, ==)

Let's delve into how these work:

The expression (50 != 2) evaluates to either true (1) or false (0), depending on the validity of the comparison.

The != operator stands for "not equal".

If 50 isn't equal to 2, then (50 != 2) evaluates to true.

In computing, the notions of "true" and "false" are numerically represented as 1 (true) and 0 (false):

  • 1 represents true;
  • 0 represents false.

Note

The binary values 0 and 1 can also represent states. We've already encountered these values when discussing byte states in a previous lesson.

For instance, with the != operator:

c

Main.c

The expression (50 != 2) evaluates to true, or 1.

The == operator checks for equality.

For instance:

c

Main.c

The expression (50 == 2) is false, or 0, because 50 is not equal to 2.

What is the output of the next code?

Select the correct answer

Everything was clear?

Section 3. Chapter 1
course content

Course Content

C Basics

Assignment, Comparison, Not Equal To

We've learned how to store data in variables, organize data into arrays, and display data as strings. Yet, we haven't explored how to modify or manipulate that data.

Assignment Operator (=)

We're already familiar with this operator. It assigns the value on the right to the variable on the left:

Comparison Operators (!=, ==)

Let's delve into how these work:

The expression (50 != 2) evaluates to either true (1) or false (0), depending on the validity of the comparison.

The != operator stands for "not equal".

If 50 isn't equal to 2, then (50 != 2) evaluates to true.

In computing, the notions of "true" and "false" are numerically represented as 1 (true) and 0 (false):

  • 1 represents true;
  • 0 represents false.

Note

The binary values 0 and 1 can also represent states. We've already encountered these values when discussing byte states in a previous lesson.

For instance, with the != operator:

c

Main.c

The expression (50 != 2) evaluates to true, or 1.

The == operator checks for equality.

For instance:

c

Main.c

The expression (50 == 2) is false, or 0, because 50 is not equal to 2.

What is the output of the next code?

Select the correct answer

Everything was clear?

Section 3. Chapter 1
some-alt