Hello everyone.Now we will discuss the relational operators.
Relational Operators are generally used to define a test expression or a test condition.These are > , < , >= , <= , == , != .
Note that == operator is used to check equality whereas = operator is used for assignment.There are also logical operators such as !,&& and || to negate a condition or to combine two conditions.
A comma operators is used to combine several expressions together which get executed from left to right.It works as a punctuator.
Ternery Operator/Conditional Operator-It is the replacement of simple Conditional operator.Its Syntax is as follows:-
(condition)?True:False;
Now coming to the Datatype conversions.These are of two types:-
1.Implicit
2.Explicit
Implicit-In Implicit type conversion the compiler converts one data type to another automatically and it actually converts all the data upto the type of largest operand available in the expression & that is why implicit type conversion is sometimes also known as type promotion.
For eg-
int to float
float x=5/7 gives answer 0.0
Explicit-It is Also known as type casting.
Eg-
float x=(float)7/5; gives answer 1.4
Now we will discuss Variable initialization and reference variable.
Variable Initialization is giving value to the variable at the time of declaration.
It can be Static or Dynamic.Examples of static and dynamic initialization are as follows-
int a=5 ;//Static-variable is initialized at the time of compilation
int a=b+c;//dynamic-variable is initialized at the time of execution
Reference Variable-A Reference variable is an alternative name to an existing variable.For eg- int a=10;
int &b=a;
here b is a reference variable or alternative name of a and cout<< b;
results in 10.
This is for Today.On the basis of which we have done till now you can try some basic programs on your own and can ask your doubts in comments.
Some Questions that you can try are:-
To display the roots of a quadratic equation,To display a prime Number or a range of prime numbers,to count and Display the number of digits in the integral part of a float type number , etc.
Goodbye and Keep Coding.
Relational Operators are generally used to define a test expression or a test condition.These are > , < , >= , <= , == , != .
Note that == operator is used to check equality whereas = operator is used for assignment.There are also logical operators such as !,&& and || to negate a condition or to combine two conditions.
A comma operators is used to combine several expressions together which get executed from left to right.It works as a punctuator.
Ternery Operator/Conditional Operator-It is the replacement of simple Conditional operator.Its Syntax is as follows:-
(condition)?True:False;
Now coming to the Datatype conversions.These are of two types:-
1.Implicit
2.Explicit
Implicit-In Implicit type conversion the compiler converts one data type to another automatically and it actually converts all the data upto the type of largest operand available in the expression & that is why implicit type conversion is sometimes also known as type promotion.
For eg-
int to float
float x=5/7 gives answer 0.0
Explicit-It is Also known as type casting.
Eg-
float x=(float)7/5; gives answer 1.4
Now we will discuss Variable initialization and reference variable.
Variable Initialization is giving value to the variable at the time of declaration.
It can be Static or Dynamic.Examples of static and dynamic initialization are as follows-
int a=5 ;//Static-variable is initialized at the time of compilation
int a=b+c;//dynamic-variable is initialized at the time of execution
Reference Variable-A Reference variable is an alternative name to an existing variable.For eg- int a=10;
int &b=a;
here b is a reference variable or alternative name of a and cout<< b;
results in 10.
This is for Today.On the basis of which we have done till now you can try some basic programs on your own and can ask your doubts in comments.
Some Questions that you can try are:-
To display the roots of a quadratic equation,To display a prime Number or a range of prime numbers,to count and Display the number of digits in the integral part of a float type number , etc.
Goodbye and Keep Coding.
Comments
Post a Comment