Difference between revisions of "Java/C2/Relational-Operations/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(12 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
   
 
   
 
{| border=1
 
{| border=1
|| ''Time'''
+
|| '''Time'''
 
|| '''Narration'''
 
|| '''Narration'''
|-
 
|  00:02
 
|  Welcome to the spoken tutorial on '''Relational Operators''' in '''C''' and '''C++'''.
 
  
 
|-
 
|-
|00:07
+
| 00:01
| In this tutorial, we will learn about:
+
| Welcome to the spoken tutorial on '''Relational Operators in Java'''.
  
 
|-
 
|-
|00;09 
+
| 00:07
|Relational operators like
+
| In this tutorial, we will learn about the
  
 
|-
 
|-
|00:12
+
| 00:09
|Less than: eg.  a < b
+
| ''' boolean data type''','''Relational operators '''and
  
 
|-
 
|-
|00:15
+
| 00:12
|Greater than: eg. a > b
+
| how to '''compare''' '''data''' using '''Relational operators.'''
  
 
|-
 
|-
|00:18
+
| 00:17
|Less than or equal to: ega <= b
+
| For this tutorial, we are using:
 +
 +
'''Ubuntu 11.10''',
 +
   
 +
'''JDK 1.6''' and
  
|-
+
'''Eclipse 3.7'''
|00:23
+
|Greater than or equal to: eg. a >= b
+
  
 
|-
 
|-
|00:28
+
| 00:26
|Equal to: eg. a == b
+
| To follow this tutorial, you must have knowledge of '''data types''' in '''Java'''.
  
 
|-
 
|-
|00:31
+
| 00:31
|Not equal to: eg. a != b
+
| If not, for relevant tutorials, please visit our  website as shown.
  
 
|-
 
|-
| 00:38
+
| 00:39
|To record this tutorial, I am using: '''Ubuntu 11.10''' as the operating system       
+
| '''Relational operators''' are used to check for conditions.
  
 
|-
 
|-
|00:43
+
| 00:43
|'''gcc''' and '''g++ Compiler '''version '''4.6.1 '''in '''Ubuntu.'''
+
| Their output is a variable of '''boolean''' data type.
  
 
|-
 
|-
|00:50
+
| 00:48
|Let us begin with an introduction.
+
| A  '''boolean''' data type is of size  1 '''bit'''.
  
 
|-
 
|-
|00:53
+
| 00:51
|Relational operators are used to compare integer and floating point numbers.
+
| It stores only two values.
  
 
|-
 
|-
|00:58
+
| 00:54
|Expressions using relational operators '''return''' 0 for false and 1 for true.
+
| '''true '''or '''false. '''
 
+
'''Return''' values:
+
 
+
0 when '''False'''
+
 
+
1 when''' True'''  
+
  
 
|-
 
|-
| 01:04
+
| 00:56
|Now I will demonstrate the relational operators with the help of a C program.
+
| '''true''' is the output when the condition is true.
  
 
|-
 
|-
| 01:10
+
| 00:59
|I have already made the program.
+
| '''false''' is the output if the condition is not true.  
  
 
|-
 
|-
|01:11
+
| 01:06
|So, I'll open the editor and explain the code.
+
|   Here is a list of the '''relational operators''' available.
  
 
|-
 
|-
| 01:16
+
| 01:10
|First, we declare two variables '''a '''and '''b'''.
+
| '''greater than'''
  
 
|-
 
|-
|01:21
+
| 01:12
|This '''printf''' statement prompts the user to enter the values of a and b.
+
| '''less than''' '''equal to'''
  
 
|-
 
|-
|01:27
+
| 01:14
|This '''scanf '''statement takes input for the variables '''a '''and '''b'''.
+
| '''greater than''' or '''equal to''' '''less than''' or '''equal to'''
  
 
|-
 
|-
| 01:33
+
| 01:17
|   Now we have the '''greater than''' operator.
+
| '''not equal to'''
  
 
|-
 
|-
|01:35
+
| 01:19
|This operator compares the two operands on either side of the operator.
+
| We shall look into each of them in detail.
  
 
|-
 
|-
|01:39
+
|01:22
|It '''returns''' ''False''' if '''a''' is greater than '''b'''.
+
| Switch to '''Eclipse.'''
  
 
|-
 
|-
| 01:44
+
|01:27 
| This '''printf '''statement is executed if the above condition is true.
+
| Here we have the '''Eclipse IDE '''and the skeleton required for the rest of the code.
  
 
|-
 
|-
|01:48
+
| 01:33
|If the above condition is '''false '''then it is skipped.
+
| I have created a class '''BooleanDemo''' and added the '''Main method'''.
  
 
|-
 
|-
|01:51
+
| 01:38
|To control then jumps to the next statement.
+
| Now let us add some expressions.
  
 
|-
 
|-
| 01:54
+
| 01:41 
We now have the '''less than''' operator.
+
Type '''boolean b ;'''
  
 
|-
 
|-
|01:56
+
| 01:47
|This too compares the operands.
+
| The keyword '''boolean''' declares the data type of the variable '''b''' as '''boolean.'''
  
 
|-
 
|-
|01:58
+
| 01:53
|It '''returns''' '''true''' when '''a''' is less than '''b'''.
+
| We shall store the result of our condition in '''b'''.
  
 
|-
 
|-
| 02:03
+
|   01:58
|This '''printf''' statement is executed if the above condition is '''true.'''
+
| We shall define a variable '''weight''' and check for a condition using that variable.
  
 
|-
 
|-
|02:07
+
| 02:05
|It is skipped otherwise.
+
| '''int weight ''' equal to '''45;'''
  
 
|-
 
|-
|02:09
+
| 02:13
Let's execute the code till here.
+
We shall check if the value in '''weight''' is greater than '''40.'''
  
 
|-
 
|-
|02:13
+
| 02:18
|First comment out the following. Type /* */ ''' '''
+
|  '''b ''' equal to '''weight ''' greater than '''40;'''
  
 
|-
 
|-
| 02:24
+
| 02:28
Click on '''Save'''.
+
This statement says: check if the value of variable is greater than 40 and store the result in 'b'.
  
 
|-
 
|-
|02:26
+
| 02:37
|I have saved my file as relational.c
+
| Now, let us print the value of 'b'.
  
 
|-
 
|-
| 02:30
+
| 02:41
|   Open the terminal window by pressing '''Ctrl, Alt and T '''keys''' '''simultaneously.
+
| '''System ''' dot  '''out''' dot  '''println(b);'''
  
 
|-
 
|-
| 02:36
+
| 02:49
To compile, type the following on the terminal '''gcc relational.c -o rel'''
+
|  '''Save''' and '''Run'''.
  
 
|-
 
|-
| 02:50
+
|  02:59
Press '''Enter'''.
+
As we can see, the output is '''True'''.
 
+
|-
+
| 02:52
+
| To execute   type '''./rel''' Press '''Enter'''.
+
 
+
+
|-
+
| 02:58
+
|  I enter '''a''' as 8 and '''b '''as 3.
+
  
 
|-
 
|-
 
| 03:02
 
| 03:02
The output is displayed:
+
Let us see what happens if the value is less than 40.
 
+
|-
+
| 03:04
+
|  8 is greater than 3.
+
  
 
|-
 
|-
 
| 03:07
 
| 03:07
You can try executing this code with different values of '''a '''and '''b'''.
+
Change '''weight''' to 30.
  
 
|-
 
|-
|03:12
+
| 03:12
| Coming back to the code.
+
'''Save''' and '''run'''.
  
 
|-
 
|-
| 03:14
+
| 03:20
Delete the comment from here  and  put it    here.
+
We can see that the output is '''False''' as expected.
 
+
+
  
 
|-
 
|-
| 03:24
+
| 03:24
|Now we have the '''less than or equal to '''operator.
+
| This way, the ''greater than'' symbol is used to check if one value is ''greater than'' the other.
  
 
|-
 
|-
| 03:29
+
| 03:30
| This operator compares the two operands on either side of the operator.
+
| Similarly, ''less than'' symbol is used to check if one value is ''less than'' the other.
  
 
|-
 
|-
| 03:33
+
| 03:37
| It '''returns''' '''true''' if '''a''' is less than or equal to '''b'''.
+
| Let us change the ''greater than'' to ''less than'' symbol.
 
+
|-
+
|03:39
+
| This '''printf '''statement is executed if the above condition is true.
+
  
 
|-
 
|-
 
| 03:43
 
| 03:43
| If the above condition is '''false '''then it is skipped.
+
| So, We are checking if the value of '''weight''' is less than '''40'''.
  
 
|-
 
|-
| 03:46
+
| 03:48
| The control then jumps to the next statement.
+
| '''Save''', '''Run'''.
  
 
|-
 
|-
| 03:50
+
| 03:56
| Next comes the '''greater than or equal to '''operator.
+
| As we can see, the output is '''true''' as expected.
 
+
|-
+
| 03:53
+
|  It compares '''a '''and '''b '''and '''returns''' '''true''' if '''a''' is greater than or equal to '''b'''.
+
  
 
|-
 
|-
 
| 04:01
 
| 04:01
| If the condition is true then this printf statement will be executed.
+
| Let us change the value of '''weight''' to 45 and see the output.
  
 
|-
 
|-
| 04:05
+
| 04:09
| Now let's execute the code till here.
+
| '''Save''' and '''Run'''.
  
 
|-
 
|-
| 04:08
+
|  04:16
Click on '''Save'''.
+
We see that we get a '''false''' because the condition
 
+
|-
+
| 04:10
+
Switch back to the terminal.
+
 
+
|-
+
| 04:12
+
|  Compile and execute as before.
+
 
+
+
|-
+
| 04:17
+
|  I enter '''a''' as 8 and '''b '''as 3.
+
  
 
|-
 
|-
| 04:23
+
| 04:21
The output is displayed:
+
'''weight''' ''less than'' '''40''' is not true.
  
 
|-
 
|-
 
| 04:25
 
| 04:25
8 is greater than or equal to 3
+
Now let us see how to check if a value is equal to another.
  
 
|-
 
|-
| 04:30
+
| 04:31
|Now Coming back to rest of the code.
+
To do that, we use two '''equal to symbols.'''
  
 
|-
 
|-
| 04:33
+
| 04:35
Delete the multiline comments from here ands here.
+
Change ''less than'' symbol to ''double equal to.''
  
 
|-
 
|-
| 04:43
+
| 04:41
|we now have the '''equal to '''operator.
+
| '''Save''' and '''Run'''.
  
 
|-
 
|-
| 04:47
+
| 04:48
It is denoted by double '''equal (==) '''signs.
+
As we can see, the output is '''false''' because the value of '''weight''' is not equal to '''40'''.
  
 
|-
 
|-
| 04:50
+
| 04:55
This operator '''returns''' '''true''' when both operands are equal to one another.
+
Now let us change the '''weight''' to 40 and see the output.
 
+
|-
+
| 04:57
+
|This '''printf''' statement executes when '''a''' is equal to '''b.'''
+
  
 
|-
 
|-
 
| 05:01
 
| 05:01
If not, the control then jumps on to the next statement.
+
'''Save''' and  '''Run'''.
  
 
|-
 
|-
|05:06
+
| 05:08
|Similarly, we have the '''not equal to''' operator.
+
| As we can see, the output is '''True'''.
  
 
|-
 
|-
| 05:09
+
| 05:12
|  This operator '''returns true''' when the operands are not equal to one another.
+
|  This way, ''double equal to'' is used for checking equality.
  
 
|-
 
|-
|05:15
+
| 05:16
| This '''printf''' statment will execute when '''a''' is not equal to '''b'''.
+
| Please be careful because, often people use a '''single equal to''' symbol for checking equality.
  
 
|-
 
|-
| 05:21
+
| 05:22
|Coming to the end of the program.
+
| And this gives unnecessary '''error'''s.
 
+
'''Return 0;'''
+
  
 
|-
 
|-
| 05:24
+
| 05:26
| Click on '''Save'''.
+
| Next we'll see how to check for '''less than or equal to.'''
  
 
|-
 
|-
|05:26
+
| 05:30
| Switch back to the terminal.
+
| To do that, we will use a '''less than''' symbol followed by an '''equal to''' symbol.
  
 
|-
 
|-
| 05:28
+
| 05:35
Compile and execute as before.
+
Change the ''double equal to'',  to ''less than equal to''.
 
+
  
 
|-
 
|-
| 05:33
+
| 05:42
Enter '''a''' as 8 and '''b '''as 3.
+
|  '''Save''' and '''Run'''.
  
 
|-
 
|-
| 05:39
+
| 05:50
| The output is displayed on the screen:
+
| The output is '''True''' as expected.
  
 
|-
 
|-
| 05:41
+
| 05:53
8 is not equal to 3
+
Now let us change the value of '''weight''' to see if the '''less than''' check is performed.
  
 
|-
 
|-
| 05:45
+
| 05:59
| So, we see how the relational operaotors work.
+
| Change '''40''' to '''30.'''
  
 
|-
 
|-
| 05:48
+
| 06:04
Try executing this code with different set of inputs.
+
'''Save''' and '''Run.'''
  
 
|-
 
|-
| 05:52
+
| 06:14
| \Now, writing a smilar program in '''C++''' is quite easy.
+
We see, that although the '''weight''' is not equal to 40 we get the output as '''True''' because it is less than 40.
 
+
|-
+
| 05:56
+
|  There are a few differences in the syntax.
+
 
+
|-
+
| 06:00
+
I have already made the code in '''C++'''.
+
 
+
|-
+
|06:04
+
| Their is the code for '''relational operators''' in '''C++'''.
+
 
+
|-
+
|06:09
+
|Notice that the header is different.
+
 
+
|-
+
| 06:12
+
|  Also we have the '''using '''statement here.
+
 
+
|-
+
| 06:16
+
|  The output statement in C++ is '''cout'''.
+
 
+
|-
+
| 06:19
+
|  And the input statement in C++ is''' cin.'''
+
  
 
|-
 
|-
 
| 06:22
 
| 06:22
So, apart from these differences, the two codes are very similar.
+
Let us see what happens if the value of '''weight''' is greater than 40.
  
 
|-
 
|-
|06:27
+
| 06:27
| Click on save.
+
| Let's say 50. '''Save and Run'''.
  
 
|-
 
|-
| 06:29
+
| 06:39
| Please make sure the file is saved with the extension '''.cpp'''
+
|As we can see, the output is '''False'''  because the value of '''weight''' is not equal to 40.
  
 
|-
 
|-
| 06:33
+
| 06:44
I have saved my file as '''relational.cpp'''
+
And it also not less than 40.
  
 
|-
 
|-
| 06:38
+
| 06:48
| Let's compile the code.
+
| Similarly, we use a ''greater than'' symbol followed by an ''equal to'' symbol for checking '''greater than''' or''' equal to'''.
  
 
|-
 
|-
| 06:40
+
| 06:55
Open the terminal and type '''g++ relational.cpp -o rel1'''
+
Let us try it.
  
 
|-
 
|-
| 06:51
+
| 06:57
| To  execute Type  '''./ rel1'', Press Enter.
+
|   Change ''less than equal to'' to ''greater than equal to''.
+
  
 
 
|-
 
|-
| 06:57
+
| 07:04
I enter '''a''' as 8 and '''b '''as 3.
+
|  '''Save''' and '''Run.'''
  
 
|-
 
|-
| 07:01
+
| 07:10
The output is displayed:
+
As we can see, the output is '''true ''' because '''weight''' is greater than '''40'''.
  
 
|-
 
|-
| 07:03
+
| 07:16
| We see that the output is same as  the one in  '''C''' code.
+
| Let us change '''weight''' to a value less than 40. Let's say 30.
  
 
|-
 
|-
| 07:08
+
| 07:25
| Now let us see an error which we can come across.
+
| '''Save''' and '''Run.'''
  
 
|-
 
|-
| 07:11
+
| 07:32
Come back to the program
+
We get a '''false''' because the value of '''weight''' is not greater than 40 and also not equal to 40.
  
 
|-
 
|-
| 07:13
+
|   07:39
| Suppose here we replace the double equal to sign with the single equal to.
+
| Next, we’ll see how to check for '''not equal to'''.
  
 
|-
 
|-
| 07:20
+
| 07:46
Click on '''Save.'''
+
It is done by using an '''exclamation mark''' followed by an '''equal to''' symbol.
  
 
|-
 
|-
| 07:21
+
| 07:53
Come back to the terminal.
+
Change ''greater than'' to ''exclamation''.
  
 
|-
 
|-
| 07:24
+
| 07:59
Compile and execute as before.
+
So, this statement says: check if the value of '''weight''' is not equal to '''40''' and store the result in '''b'''.
  
 
|-
 
|-
| 07:34
+
| 08:08
| Here we see it is showing 3 is equal to 3.
+
| '''Save''' and '''Run'''.
  
 
|-
 
|-
| 07.38
+
| 08:16
| Come back to our program
+
| As we can see, the output is '''true''' because the values of weight is not equal to 40.
  
 
|-
 
|-
| 07:40
+
| 08:23
| This is because here we have an assignment operator.
+
| Let us change the '''weight''' to 40 and see the output.
  
 
|-
 
|-
| 07:44
+
| 08:28
| So value of b is assigned to a.
+
| Change 30 to 40.
  
 
|-
 
|-
| 07:47
+
| 08:31
|Now  Let us fix this error.
+
| '''Save, Run'''.
  
 
|-
 
|-
| 07:49
+
| 08:38
| Type an equal to sign.
+
| We get a '''false''' because the condition '''weight''' not equal to 40 is false.
  
 
|-
 
|-
| 07:52
+
| 08:45
| Click on '''Save'''
+
| The '''not equal''' to condition can be thought of as opposite of '''equal to''' condition.
  
 
|-
 
|-
07:55
+
08:50
| Switch back to  the terminal
+
| This is how we use the various '''relational operators''' to compare data in Java.
  
 
|-
 
|-
| 07:56
+
| 08:58
compile and execute as before.
+
| This brings us to the end of this tutorial.  
  
 
|-
 
|-
| 08:04
+
| 09:01
| The output is now correct.
+
| In this tutorial we have learnt about: the boolean data type,
  
 
|-
 
|-
|08:06
+
| 09:06
| Let's summarize the tutorial.
+
| the '''relational operators''' and
  
 
|-
 
|-
| 08:09
+
| 09:08
In this tutorial, we learnt
+
how to use '''relational operators''' to compare data.
  
 
|-
 
|-
| 08:10
+
| 09:13
| Relational operators like
+
| As an assignment for this tutorial, find out if the two expressions shown are equivalent.
  
 
|-
 
|-
| 08:12
+
| 09:23
| Less than: eg. a <b
+
|To know more about the Spoken Tutorial project,watch the video available at [http://spoken-tutorial.org/What_is_a_Spoken_Tutorial].  
  
 
|-
 
|-
| 08:15
+
| 09:28
| Greater than: eg. a>b
+
| It summarizes the Spoken Tutorial project.
  
 
|-
 
|-
| 08:18
+
| 09:31
| Less than or equal to:  eg. a<=b
+
| If you do not have good bandwidth, you can download and watch it.
  
 
|-
 
|-
| 08:23
+
| 09:36
| Greater than or equal to: eg. a>=b
+
| The Spoken Tutorial Project Team:
  
 
|-
 
|-
| 08:27
+
| 09:38
| Equal to: eg. a==b
+
| Conducts workshops using 'Spoken Tutorials'.
  
 
|-
 
|-
| 08:30
+
| 09:40
| Not equal to: eg. a!=b
+
| Gives certificates for those who pass an online test. For more details, please write to '''contact AT spoken HYPHEN tutorial DOT org.'''
  
 
|-
 
|-
| 08:34
+
| 09:50
| As an assignment
+
| Spoken Tutorial Project is a part of the 'Talk to a Teacher' project.
  
 
|-
 
|-
| 08:35
+
| 09:54
Write a program that takes the marks of three students as input.
+
It is supported by the National Mission on Education through ICT, MHRD, Government of India.  
  
 
|-
 
|-
| 08:40
+
| 10:00
| Compare the marks to see which student has scored the highest.
+
| More information on this mission is available at '''spoken HYPHEN tutorial DOT org SLASH NMEICT HYPHEN Intro'''.
  
 
|-
 
|-
| 08:44
+
| 10:05
| Check also if two or more students have scored equal marks.
+
| This tutorial has been contributed by '''TalentSprint'''. Thanks for joining.
 
+
|-
+
|  08:49
+
|  Watch the video available at the following link
+
|-
+
| 08:51
+
|  It summarises the Spoken Tutorial project
+
|-
+
| 08:54
+
|  If you do not have good bandwidth, you can download and watch it
+
 
+
 
+
 
+
|-
+
| 08:58
+
|  The Spoken Tutorial Project Team
+
|-
+
| 09:00
+
|  Conducts workshops using spoken tutorials
+
|-
+
| 09:03
+
|  Gives certificates for those who pass an online test
+
|-
+
| 09:06
+
|  For more details, please write to contact at spoken hyphen tutorial dot org
+
 
+
 
+
 
+
|-
+
| 09:14
+
|  Spoken Tutorial Project is a part of the Talk to a Teacher project
+
|-
+
| 09:18
+
|  It is supported by the National Mission on Education through ICT, MHRD, Government of India |-
+
| 09:24
+
|  More information on this Mission is available at
+
|-
+
| 09:27
+
|  spoken hyphen tutorial dot org slash NMEICT hyphen Intro
+
 
+
 
+
 
+
|-
+
|  09:35
+
|  This is Ritwik Joshi from IIT Bombay.  
+
 
+
Thank you for joining.  
+
  
 
|}
 
|}

Latest revision as of 15:55, 7 April 2017

Time Narration
00:01 Welcome to the spoken tutorial on Relational Operators in Java.
00:07 In this tutorial, we will learn about the
00:09 boolean data type,Relational operators and
00:12 how to compare data using Relational operators.
00:17 For this tutorial, we are using:

Ubuntu 11.10,

JDK 1.6 and

Eclipse 3.7

00:26 To follow this tutorial, you must have knowledge of data types in Java.
00:31 If not, for relevant tutorials, please visit our website as shown.
00:39 Relational operators are used to check for conditions.
00:43 Their output is a variable of boolean data type.
00:48 A boolean data type is of size 1 bit.
00:51 It stores only two values.
00:54 true or false.
00:56 true is the output when the condition is true.
00:59 false is the output if the condition is not true.
01:06 Here is a list of the relational operators available.
01:10 greater than
01:12 less than equal to
01:14 greater than or equal to less than or equal to
01:17 not equal to
01:19 We shall look into each of them in detail.
01:22 Switch to Eclipse.
01:27 Here we have the Eclipse IDE and the skeleton required for the rest of the code.
01:33 I have created a class BooleanDemo and added the Main method.
01:38 Now let us add some expressions.
01:41 Type boolean b ;
01:47 The keyword boolean declares the data type of the variable b as boolean.
01:53 We shall store the result of our condition in b.
01:58 We shall define a variable weight and check for a condition using that variable.
02:05 int weight equal to 45;
02:13 We shall check if the value in weight is greater than 40.
02:18 b equal to weight greater than 40;
02:28 This statement says: check if the value of variable is greater than 40 and store the result in 'b'.
02:37 Now, let us print the value of 'b'.
02:41 System dot out dot println(b);
02:49 Save and Run.
02:59 As we can see, the output is True.
03:02 Let us see what happens if the value is less than 40.
03:07 Change weight to 30.
03:12 Save and run.
03:20 We can see that the output is False as expected.
03:24 This way, the greater than symbol is used to check if one value is greater than the other.
03:30 Similarly, less than symbol is used to check if one value is less than the other.
03:37 Let us change the greater than to less than symbol.
03:43 So, We are checking if the value of weight is less than 40.
03:48 Save, Run.
03:56 As we can see, the output is true as expected.
04:01 Let us change the value of weight to 45 and see the output.
04:09 Save and Run.
04:16 We see that we get a false because the condition
04:21 weight less than 40 is not true.
04:25 Now let us see how to check if a value is equal to another.
04:31 To do that, we use two equal to symbols.
04:35 Change less than symbol to double equal to.
04:41 Save and Run.
04:48 As we can see, the output is false because the value of weight is not equal to 40.
04:55 Now let us change the weight to 40 and see the output.
05:01 Save and Run.
05:08 As we can see, the output is True.
05:12 This way, double equal to is used for checking equality.
05:16 Please be careful because, often people use a single equal to symbol for checking equality.
05:22 And this gives unnecessary errors.
05:26 Next we'll see how to check for less than or equal to.
05:30 To do that, we will use a less than symbol followed by an equal to symbol.
05:35 Change the double equal to, to less than equal to.
05:42 Save and Run.
05:50 The output is True as expected.
05:53 Now let us change the value of weight to see if the less than check is performed.
05:59 Change 40 to 30.
06:04 Save and Run.
06:14 We see, that although the weight is not equal to 40 we get the output as True because it is less than 40.
06:22 Let us see what happens if the value of weight is greater than 40.
06:27 Let's say 50. Save and Run.
06:39 As we can see, the output is False because the value of weight is not equal to 40.
06:44 And it also not less than 40.
06:48 Similarly, we use a greater than symbol followed by an equal to symbol for checking greater than or equal to.
06:55 Let us try it.
06:57 Change less than equal to to greater than equal to.
07:04 Save and Run.
07:10 As we can see, the output is true because weight is greater than 40.
07:16 Let us change weight to a value less than 40. Let's say 30.
07:25 Save and Run.
07:32 We get a false because the value of weight is not greater than 40 and also not equal to 40.
07:39 Next, we’ll see how to check for not equal to.
07:46 It is done by using an exclamation mark followed by an equal to symbol.
07:53 Change greater than to exclamation.
07:59 So, this statement says: check if the value of weight is not equal to 40 and store the result in b.
08:08 Save and Run.
08:16 As we can see, the output is true because the values of weight is not equal to 40.
08:23 Let us change the weight to 40 and see the output.
08:28 Change 30 to 40.
08:31 Save, Run.
08:38 We get a false because the condition weight not equal to 40 is false.
08:45 The not equal to condition can be thought of as opposite of equal to condition.
08:50 This is how we use the various relational operators to compare data in Java.
08:58 This brings us to the end of this tutorial.
09:01 In this tutorial we have learnt about: the boolean data type,
09:06 the relational operators and
09:08 how to use relational operators to compare data.
09:13 As an assignment for this tutorial, find out if the two expressions shown are equivalent.
09:23 To know more about the Spoken Tutorial project,watch the video available at [1].
09:28 It summarizes the Spoken Tutorial project.
09:31 If you do not have good bandwidth, you can download and watch it.
09:36 The Spoken Tutorial Project Team:
09:38 Conducts workshops using 'Spoken Tutorials'.
09:40 Gives certificates for those who pass an online test. For more details, please write to contact AT spoken HYPHEN tutorial DOT org.
09:50 Spoken Tutorial Project is a part of the 'Talk to a Teacher' project.
09:54 It is supported by the National Mission on Education through ICT, MHRD, Government of India.
10:00 More information on this mission is available at spoken HYPHEN tutorial DOT org SLASH NMEICT HYPHEN Intro.
10:05 This tutorial has been contributed by TalentSprint. Thanks for joining.

Contributors and Content Editors

Gaurav, PoojaMoolya, Ranjana, Sandhya.np14, Sneha