LESSON 6-Researved Keywords and Operators
LESSON 6-Researved Keywords and Operators
LESSON 6-Researved Keywords and Operators
IN
PROGRAMMING
STUDY THIS CODE
KEYWORDS
#include <stdio.h>
main()
{
int float;
float = 10;
printf( "Value of float = %d\n", float);
}
KEYWORDS
So far, we have covered two important
concepts called variables and their data
types.
We discussed how to use int, long, and
float to specify different data types.
We also learnt how to name the variables to
store different values.
KEYWORDS
Like int, long, and float, there are
many other keywords supported by C
programming language which we will
use for different purpose.
Different programming languages
provide different set of reserved
keywords,
KEYWORDS
There is one important &
common rule in all the
programming languages
that we cannot use a reserved
keyword to name our
variables.
KEYWORDS
What does this mean?
It means we cannot name our
variable like int or float
rather these keywords can
only be used to specify a
variable data type.
KEYWORDS
For example,
if you will try to use any
reserved keyword for the
purpose of variable name, then
you will get a syntax error.
KEYWORDS
#include <stdio.h>
main()
{
int float;
float = 10;
printf( "Value of float = %d\n", float);
}
KEYWORDS
When you compile the
above program, it produces
an error:
Programming Reserved Keywords
(A > B)
Relational Operators
Here, we used a symbol > and it is called a
relational operator
in their simplest form, they produce Boolean
results which means the result will be either
true or
false.
Similarly, a programming language provides
various relational operators.
Relational Operators
The table on (Page 32) lists down a
few of the important relational
operators available in C
programming language.
Assume variable A holds 10 and
variable B holds 20, then:
Relational Operators
Here, we will discuss one example
of C Programming which makes
use of if conditional statement.
Though this statement will be
discussed later in our next separate
lesson.
We use if statement to check a
condition and if the condition is true,
then the body of if statement is
executed, otherwise the body of if
statement is skipped.
Refer to page 33 for code
Logical Operators
Logical Operators
Logical operators are very
important in an
programming language and
they help us take decisions
based on certain conditions.
Logical Operators
Suppose we want to combine the
result of two conditions, then logical
AND
OR
logical operators help us in producing
the final result.
Logical Operators
The following table
shows(Refer to pg 34) all the
logical operators supported by
the C language.
Assume variable A holds 1 and
variable B holds 0, then:
Logical Operators
LAB ACTIVITY
Try the following example to
understand all the logical
operators available in C
programming language:
Refer to book pg 35
Operators in Java
Increment and decrement operators