Program looping is often desirable in coding in any language to have the ability to repeat a block of statements a number of times. In C, there are statements that allow iteration of this type. Specifically, there are two classes of program loops unconditional and conditional. An unconditional loop is repeated a set number of times. In a conditional loop the iterations are halted when a certain condition is true. Thus the actual number of iterations performed can vary each time the loop is executed.
Expression in Relational Operators
Our first use of these operators will be to set up the condition required to control a conditional loop. Relational operators allow the comparison of two expressions.
Such as a < 4
Which reads a “less than” 4 means a is less than 4
this expression will evaluate to TRUE, If not it will evaluate to FALSE.
Expression in Relational Operators
Our first use of these operators will be to set up the condition required to control a conditional loop. Relational operators allow the comparison of two expressions.
Such as a < 4
Which reads a “less than” 4 means a is less than 4
this expression will evaluate to TRUE, If not it will evaluate to FALSE.
Exactly what does it mean to say an expression is TRUE or FALSE? Causes the following definition
FALSE means evaluates to ZERO
TRUE means evaluates to any NON-ZERO integer (even negative integers)
FALSE means evaluates to ZERO
TRUE means evaluates to any NON-ZERO integer (even negative integers)
Relational OperatorsThe following table shows the various C relational operators
== Equal to count == 10
!= Not equal to flag != DONE
< Less than a < b
<= Less than or equal to i <= LIMIT
> Greater than pointer > end_of_list
>= Greater than or equal to lap >= start
This is a simple Program how Relational operators are used
#include <stdio.h>
int main(void)
{
int x;
x = 10;
if(x == 10)
{
int x; /* this x hides the outer x */
x = 99;
printf("Inner x: %dn", x);
}
}
== Equal to count == 10
!= Not equal to flag != DONE
< Less than a < b
<= Less than or equal to i <= LIMIT
> Greater than pointer > end_of_list
>= Greater than or equal to lap >= start
This is a simple Program how Relational operators are used
#include <stdio.h>
int main(void)
{
int x;
x = 10;
if(x == 10)
{
int x; /* this x hides the outer x */
x = 99;
printf("Inner x: %dn", x);
}
}
No comments:
Post a Comment