# Relational and logical operators

Relational operators are used to compare values with each other. They return a logical result: `true` or `false`. Values that are linked with relational operators are called elementary statements in propositional logic.
A typical example of a Boolean logical operator is the `and` operation: It always returns `true` if all operands are also `true`.

## Example

### Code Explanation

``````#include &lt;iostream&gt;
using namespace std;

int main() {
int a = 0, i = 20, b = 8;
while (a != b && i >= a+b) {
cout << a << " is equal " << b << endl;
a++;
}
cout << a << " is unequal " << b << endl;
}``````
##### Output
``````0 is equal 8
1 is equal 8
2 is equal 8
3 is equal 8
4 is equal 8
5 is equal 8
6 is equal 8
7 is equal 8
8 is unequal 8``````
{"ft_lang_label":"__label__en","ft_lang_prob":0.89933985,"math_prob":0.99946064,"size":3503,"snap":"2022-40-2023-06","text_gpt3_token_len":795,"char_repetition_ratio":0.12946557,"word_repetition_ratio":0.06031746,"special_character_ratio":0.22951755,"punctuation_ratio":0.08066971,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99913853,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-09-24T18:33:33Z\",\"WARC-Record-ID\":\"<urn:uuid:e342a09f-27de-431e-b402-d97f1800d136>\",\"Content-Length\":\"224613\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:0775132b-fc7e-4542-8b3f-e81c53e33a7e>\",\"WARC-Concurrent-To\":\"<urn:uuid:d667e7d5-3b08-41b6-86f4-9aa722dda033>\",\"WARC-IP-Address\":\"217.160.0.234\",\"WARC-Target-URI\":\"https://codevisionz.com/lessons/cpp-relational-and-logical-operators/\",\"WARC-Payload-Digest\":\"sha1:FR52QBEJ3XVEQGZGMBRWEWFBMBML7SNU\",\"WARC-Block-Digest\":\"sha1:VI46SLU7TTMVO4PHXYOCTQ23446SYJWH\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-40/CC-MAIN-2022-40_segments_1664030333455.97_warc_CC-MAIN-20220924182740-20220924212740-00027.warc.gz\"}"}