Open in App
Not now

# What is the difference between = (Assignment) and == (Equal to) operators

• Difficulty Level : Easy
• Last Updated : 21 Feb, 2023

= operator

The “=” is an assignment operator used to assign the value on the right to the variable on the left.

For example:

```a = 10;
b = 20;
ch = 'y';```

Example:

## C

 `// C program to demonstrate``// working of Assignment operators` `#include ` `int` `main()``{` `    ``// Assigning value 10 to a``    ``// using "=" operator``    ``int` `a = 10;``    ``printf``("Value of a is %d\n", a);` `    ``return` `0;``}`

Output:

`Value of a is 10`

== operator

The ‘==’ operator checks whether the two given operands are equal or not. If so, it returns true. Otherwise it returns false.

For example:

```5==5

This will return true.```

Example:

## C

 `// C program to demonstrate``// working of relational operators``#include ` `int` `main()``{``    ``int` `a = 10, b = 4;` `    ``// equal to``    ``if` `(a == b)``        ``printf``("a is equal to b\n");``    ``else``        ``printf``("a and b are not equal\n");` `    ``return` `0;``}`

Output:

`a and b are not equal`

The differences can be shown in tabular form as follows:

My Personal Notes arrow_drop_up
{"ft_lang_label":"__label__en","ft_lang_prob":0.74828285,"math_prob":0.9914993,"size":1420,"snap":"2023-14-2023-23","text_gpt3_token_len":385,"char_repetition_ratio":0.13206215,"word_repetition_ratio":0.06037736,"special_character_ratio":0.3007042,"punctuation_ratio":0.14383562,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9982669,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-04-01T19:48:15Z\",\"WARC-Record-ID\":\"<urn:uuid:d9e01fef-a754-4ad3-8104-f5eba3db4a73>\",\"Content-Length\":\"181484\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:d83ec4c4-50f1-4ba1-9e5c-7f7fe4f7d7e6>\",\"WARC-Concurrent-To\":\"<urn:uuid:419ffd34-e3ab-4606-bde9-c70135dda330>\",\"WARC-IP-Address\":\"23.40.62.17\",\"WARC-Target-URI\":\"https://www.geeksforgeeks.org/what-is-the-difference-between-assignment-and-equal-to-operators/?ref=leftbar-rightbar\",\"WARC-Payload-Digest\":\"sha1:X33QFKGKEPTLTFGY3L3AOI4266P67BHJ\",\"WARC-Block-Digest\":\"sha1:7TEMO3GXUGASJDJQJXIWXLGDPLP3YXKX\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-14/CC-MAIN-2023-14_segments_1679296950247.65_warc_CC-MAIN-20230401191131-20230401221131-00170.warc.gz\"}"}