C operations manual




















Alternately, if you specify which elements to initialize, then the size of the array is equal to the highest element number initialized, plus one. In that example, only four elements are initialized, but the last one initialized is element number 99, so there are elements.

You can access the elements of an array by specifying the array name, followed by the element index, enclosed in brackets. Remember that the array elements are numbered starting with zero. That assigns the value 5 to the first element in the array, at position zero. You can treat individual array elements like variables of whatever data type the array is made up of.

For example, if you have an array made of a structure data type, you can access the structure elements like this:. You do this by adding an extra set of brackets and array lengths for every additional dimension you want your array to have. For example, here is a declaration for a two-dimensional array that holds five elements in each dimension a two-element array consisting of five-element arrays :.

You can use an array of characters to hold a string see String Constants. The array may be built of either signed or unsigned characters. When you declare the array, you can specify the number of elements it will have. That number will be the maximum number of characters that should be in the string, including the null character used to end the string.

If you choose this option, then you do not have to initialize the array when you declare it. Alternately, you can simply initialize the array to a value, and its size will then be exactly large enough to hold whatever string you used to initialize it. There are two different ways to initialize the array. You can specify of comma-delimited list of characters enclosed in braces, or you can specify a string literal enclosed in double quotation marks.

Note that if you initialize a string using an array of individual characters, then the null character is not guaranteed to be present. It might be, but such an occurrence would be one of chance, and should not be relied upon.

After initialization, you cannot assign a new string literal to an array using the assignment operator. For example, this will not work :. However, there are functions in the GNU C library that perform operations including copy on string arrays. You can also change one character at a time, by accessing individual string elements as you would any other array:.

It is possible for you to explicitly state the number of elements in the array, and then initialize it using a string that has more characters than there are elements in the array.

This is not a good thing. The larger string will not override the previously specified size of the array, and you will get a compile-time warning.

Since the original array size remains, any part of the string that exceeds that original size is being written to a memory location that was not allocated for it. You can also initialize the first members of the elements of a number array:. After initialization, you can still access the union members in the array using the member access operator. You put the array name and element number enclosed in brackets to the left of the operator, and the member name to the right.

You can also initialize the elements of a structure array:. As with initializing structures which contain structure members, the additional inner grouping braces are optional. But, if you use the additional braces, then you can partially initialize some of the structures in the array, and fully initialize others:.

In that example, the first element of the array has only its x member initialized. Because of the grouping braces, the value 4 is assigned to the x member of the second array element, not to the y member of the first element, as would be the case without the grouping braces.

After initialization, you can still access the structure members in the array using the member access operator. Pointers hold memory addresses of stored constants or variables.

For any data type, including both primitive types and custom types, you can create a pointer that holds the memory address of an instance of that type. You declare a pointer by specifying a name for it and a data type. The data type indicates of what type of variable the pointer will hold memory addresses. To declare a pointer, include the indirection operator see Pointer Operators before the identifier.

Here is the general form of a pointer declaration:. Be careful, though: when declaring multiple pointers in the same statement, you must explicitly declare each as a pointer, using the indirection operator:. You can initialize a pointer when you first declare it by specifying a variable address to store in it.

Note the use of the address operator see Pointer Operators , used to get the memory address of a variable. On the contrary, that would change the value of the variable that the points to, not the value of the pointer itself. If you are so inclined, you can assign pointer values explicitly using literal integers, casting them to the appropriate pointer type.

However, we do not recommend this practice unless you need to have extremely fine-tuned control over what is stored in memory, and you know exactly what you are doing. It would be all too easy to accidentally overwrite something that you did not intend to. Most uses of this technique are also non-portable. It is important to note that if you do not initialize a pointer with the address of some other existing object, it points nowhere in particular and will likely make your program crash if you use it formally, this kind of thing is called undefined behavior.

That example creates a new union type, union numbers , and declares and initializes the first member of a variable of that type named foo. Finally, it declares a pointer to the type union numbers , and gives it the address of foo. Instead, you have to use the indirect member access operator see Member Access Expressions.

Continuing with the previous example, the following example will change the value of the first member of foo :. That example creates a new structure type, struct fish , and declares and initializes a variable of that type named salmon.

Finally, it declares a pointer to the type struct fish , and gives it the address of salmon. Continuing with the previous example, the following example will change the values of the members of salmon :. Now the length and width members in salmon are 5.

You can define structures, unions, and enumerations without listing their members or values, in the case of enumerations. Doing so results in an incomplete type. At some time later in your program you will want to complete the type. You do this by defining it as you usually would:. There are two type qualifiers that you can prepend to your variable declarations which change how the variables may be accessed: const and volatile.

In addition to helping to prevent accidental value changes, declaring variables with const can aid the compiler in code optimization. You might use volatile variables to store data that is updated via callback functions or signal handlers. Sequence Points and Signal Delivery. There are four storage class specifiers that you can prepend to your variable declarations which change how the variables are stored in memory: auto , extern , register , and static.

You use auto for variables which are local to a function, and whose values should be discarded upon return from the function in which they are declared.

This is the default behavior for variables declared within functions. You cannot use the address-of operator to obtain the address of a variable declared with register. This means that you cannot refer to the elements of an array declared with storage class register. In fact the only thing you can do with such an array is measure its size with sizeof.

GCC normally makes good choices about which values to hold in registers, and so register is not often used. This is known as static storage duration. You can also declare variables or functions at the top level that is, not inside a function to be static ; such variables are visible global to the current source file but not other source files. This gives an unfortunate double meaning to static ; this second meaning is known as static linkage. Two functions or variables having static linkage in separate files are entirely separate; neither is visible outside the file in which it is declared.

Uninitialized variables that are declared as extern are given default values of 0 , 0. Uninitialized variables that are declared as auto or register including the default usage of auto are left uninitialized, and hence should not be assumed to hold any particular value.

You cannot initialize a variable in an extern declaration, as no space is actually allocated during the declaration. You must make both an extern declaration typically in a header file that is included by the other source files which need to access the variable and a non- extern declaration which is where space is actually allocated to store the variable.

The extern declaration may be repeated multiple times. See Program Structure and Scope , for related information. Sometimes it is convenient to give a new name to a type. You can do this using the typedef statement.

See The typedef Statement , for more information. An expression consists of at least one operand and zero or more operators. Operands are typed objects such as constants, variables, and function calls that return values. Innermost expressions are evaluated first. Then 12 is subtracted from 13 , resulting in 1. Finally, 1 is multiplied by 2 , resulting in 2. The outermost parentheses are completely optional.

An operator specifies an operation to be performed on its operand s. Operators may have one, two, or three operands, depending on the operator. Assignment operators store values in variables. C provides several variations of assignment operators. Note that, unlike the other assignment operators described below, you can use the plain assignment operator to store values of a structure type.

Compound assignment operators perform an operation involving both the left and right operands, and then assign the resulting expression to the left operand. Here is a list of the compound assignment operators, and a brief description of what they do:.

Subtract the right operand from the left operand, and then assign the result of the subtraction to the left operand. Multiply the two operands together, and then assign the result of the multiplication to the left operand. Divide the left operand by the right operand, and assign the result of the division to the left operand.

Perform modular division on the two operands, and assign the result of the division to the left operand. Perform a left shift operation on the left operand, shifting by the number of bits specified by the right operand, and assign the result of the shift to the left operand.

Perform a right shift operation on the left operand, shifting by the number of bits specified by the right operand, and assign the result of the shift to the left operand. Perform a bitwise conjunction operation on the two operands, and assign the result of the operation to the left operand.

Performs a bitwise exclusive disjunction operation on the two operands, and assign the result of the operation to the left operand.

Performs a bitwise inclusive disjunction operation on the two operands, and assign the result of the operation to the left operand. Since there are no side effects wrought by evaluating the variable x as an lvalue, the above code produces the same result as:. The operand must be a either a variable of one of the primitive data types, a pointer, or an enumeration variable. You can apply the increment operator either before or after the operand.

Note that incrementing a pointer only makes sense if you have reason to believe that the new pointer value will be a valid memory address. A prefix increment adds 1 before the operand is evaluated. A postfix increment adds 1 after the operand is evaluated. In the previous examples, changing the position of the operator would make no difference. However, there are cases where it does make a difference:.

C provides operators for standard arithmetic operations: addition, subtraction, multiplication, and division, along with modular division and negation. Usage of these operators is straightforward; here are some examples:. However, if either operand is negative, the direction of rounding is implementation-defined. Signed Integer Division for information about overflow in signed integer division.

The operands must be expressions of a primitive data type. Modular division returns the remainder produced after performing integer division on the two operands.

The operands must be of a primitive integer type. If the operand you use with the negative operator is of an unsigned data type, then the result cannot negative, but rather is the maximum value of the unsigned data type, minus the value of the operand. Many systems use twos-complement arithmetic, and on such systems the most negative value a signed type can hold is further away from zero than the most positive value. For example, on one platform, this program:.

Numeric values are assumed to be positive unless explicitly made negative, so this operator has no effect on program operation. The operand must be an expression of a complex number type. You use the comparison operators to determine how two operands relate to each other: are they equal to each other, is one larger than the other, is one smaller than the other, and so on. When you use any of the comparison operators, the result is either 1 or 0, meaning true or false, respectively.

In the following code examples, the variables x and y stand for any two expressions of arithmetic types, or pointers. The result is 1 if the operands are equal, and 0 if the operands are not equal. The not-equal-to operator! The result is 1 if the operands are not equal, and 0 if the operands are equal. Comparing floating-point values for exact equality or inequality can produce unexpected results. Real Number Types for more information.

You can compare function pointers for equality or inequality; the comparison tests if two function pointers point to the same function or not. Beyond equality and inequality, there are operators you can use to test if one value is less than, greater than, less-than-or-equal-to, or greater-than-or-equal-to another value.

Here are some code samples that exemplify usage of these operators:. Logical operators test the truth value of a pair of operands. Any nonzero expression is considered true in C, while an expression that evaluates to zero is considered false. If the first expression is false, then the second expression is not evaluated. The logical disjunction operator tests if at least one of two expressions it true. If the first expression is true, then the second expression is not evaluated.

You can prepend a logical expression with a negation operator! Since the second operand in a logical expression pair is not necessarily evaluated, you can write code with perhaps unintuitive results:. If foo is ever zero, then not only would bar not be called, but x would not be incremented. If you intend to increment x regardless of the value of foo , you should do so outside of the conjunction expression. The second operand denotes the number of bit places to shift. Bits shifted off the left side of the value are discarded; new bits added on the right side will all be 0.

Bits shifted off the right side are discarded; new bits added on the left side are usually 0, but if the first operand is a signed negative value, then the added bits will be either 0 or whatever value was previously in the leftmost bit position. You can use the shift operators to perform a variety of interesting hacks. For example, given a date with the day of the month numbered as d , the month numbered as m , and the year y , you can store the entire date in a single number x :.

You can then extract the original day, month, and year out of x using a combination of shift operators and modular division:. C provides operators for performing bitwise conjunction, inclusive disjunction, exclusive disjunction, and negation complement. Biwise conjunction examines each bit in its two operands, and when two corresponding bits are both 1, the resulting bit is 1. All other resulting bits are 0.

Here is an example of how this works, using binary numbers:. Bitwise inclusive disjunction examines each bit in its two operands, and when two corresponding bits are both 0, the resulting bit is 0. All other resulting bits are 1. Bitwise exclusive disjunction examines each bit in its two operands, and when two corresponding bits are different, the resulting bit is 1. In C, you can only use these operators with operands of an integer or character type, and for maximum portability, you should only use the bitwise negation operator with unsigned integer types.

Here are some examples of using these operators in C code:. Function pointers and data pointers are not compatible, in the sense that you cannot expect to store the address of a function into a data pointer, and then copy that into a function pointer and call it successfully. See The goto Statement. This is called dereferencing the pointer. You can use the sizeof operator to obtain the size in bytes of the data type of its operand.

The operand may be an actual type specifier such as int or float , as well as any valid expression. When the operand is a type name, it must be enclosed in parentheses. The sizeof operator can be used to automatically compute the number of elements in an array:. There are two cases where this technique does not work.

The second is where the array is in fact a function parameter see Function Parameters. You can use a type cast to explicitly cause an expression to be of a specified data type. A type cast consists of a type specifier enclosed in parentheses, followed by an expression.

To ensure proper casting, you should also enclose the expression that follows the type specifier in parentheses. In that example, since y and z are both integers, integer division is performed, and even though x is a floating-point variable, it receives the value 2. To fix this problem, you need to convert one of the operands to a floating-point type before the division takes place:. Type casting only works with scalar types that is, integer, floating-point or pointer types.

Therefore, this is not allowed:. You can access array elements by specifying the name of the array, and the array subscript or index, or element number enclosed in brackets. This means that many uses of an array name are equivalent to a pointer expression. It also means that you cannot subscript an array having the register storage class. You use the comma operator , to separate two ostensibly related expressions. For instance, the first expression might produce a value that is used by the second expression:.

This lets you conveniently set, monitor, and modify multiple control expressions for the for statement. A comma is also used to separate function parameters; however, this is not the comma operator in action.

In fact, if the comma operator is used as we have discussed here in a function call, then the compiler will interpret that as calling the function with an extra parameter.

If you want to use the comma operator in a function argument, you need to put parentheses around it. You can use the member access operator. You use the conditional operator to cause the entire conditional expression to evaluate to either its second or its third operand, based on the truth value of its first operand. If expression a is true, then expression b is evaluated and the result is the value of b. Otherwise, expression c is evaluated and the result is c.

Here, if x equals 5, then a will receive the value of y. Otherwise, a will receive the value of z. This can be considered a shorthand method for writing a simple if … else statement. The following example will accomplish the same task as the previous one:. If the first operand of the conditional operator is true, then the third operand is never evaluated.

Similarly, if the first operand is false, then the second operand is never evaluated. The first operand is always evaluated. As a GNU C extension, you can build an expression using compound statement enclosed in parentheses. This allows you to included loops, switches, and local variables within an expression. Recall that a compound statement also known as a block is a sequence of statements surrounded by braces. In this construct, parentheses go around the braces. That is a valid though slightly more complex than necessary expression for the absolute value of function.

The last thing in the compound statement should be an expression followed by a semicolon; the value of this subexpression serves as the value of the entire construct. If you use some other kind of statement last within the braces, the construct has type void , and thus effectively no value. But this definition computes either a or b twice, with bad results if the operand has side effects.

Embedded statements are not allowed in constant expressions, such as the value of an enumeration constant, the width of a bit field, or the initial value of a static variable. For instance, the meaning of that expression is to call the function f with no arguments, multiply the result by b , then add that result to a. The following is a list of types of expressions, presented in order of highest precedence first.

Sometimes two or more operators have equal precedence; all those operators are applied from left to right unless stated otherwise. The above list is somewhat dry and is apparently straightforward, but it does hide some pitfalls. Take this example:. There are other examples of potential surprises lurking behind the C precedence table. For this reason if there is the slightest risk of the reader misunderstanding the meaning of the program, you should use parentheses to make your meaning clear.

In C you cannot assume that multiple subexpressions are evaluated in the order that seems natural. Does this increment a before or after calling the function f? The compiler could do it in either order, so you cannot make assumptions.

This manual explains the semantics of the C language in the abstract. However, an actual compiler translates source code into specific actions in an actual computer, and may re-order operations for the sake of efficiency. The correspondence between the program you write and the things the computer actually does are specified in terms of side effects and sequence points.

These are essentially the externally-visible effects of running a program. The compiler is allowed to perform the operations of your program in an order different to the order implied by the source of your program, provided that in the end all the necessary side effects actually take place. Another requirement on the compiler is that side effects should take place in the correct order.

In order to provide this without over-constraining the compiler, the C89 and C90 standards specify a list of sequence points. A sequence point is one of the following:. At a sequence point, all the side effects of previous expression evaluations must be complete, and no side effects of later evaluations may have taken place.

This may seem a little hard to grasp, but there is another way to consider this. Imagine you wrote a library some of whose functions are external and perhaps others not and compiled it, allowing someone else to call one of your functions from their code.

The definitions above ensure that, at the time they call your function, the data they pass in has values which are consistent with the behaviour specified by the abstract machine, and any data returned by your function has a state which is also consistent with the abstract machine. This includes data accessible via pointers i. The above is a slight simplification, since compilers exist that perform whole-program optimisation at link time.

Importantly however, although they might perform optimisations, the visible side effects of the program must be the same as if they were produced by the abstract machine. The C standards both C89 and C99 both forbid this construct in conforming programs. Not allowed in a conforming program; modifies x twice before argument evaluation is complete. Allowed; the function bar takes one argument the value 2 is passed here , and there is a sequence point at the comma operator.

Allowed; there is a sequence point at the end of the controlling expression of the if 3. Allowed; there is a sequence point before the? Not allowed; the object at p is being modified twice before the evaluation of the arguments to bar is complete. The fact that this is done once via p and once via q is irrelevant, since they both point to the same object.

Suppose the code actually looks like this:. Is this code allowed in a standard-conforming program? Although the expression in foo modifies a twice, this is not a problem. Since f returns a value other than void, it must contain a return statement. Therefore, there is a sequence point at the end of the return expression. That comes between the modification to a that f makes and the evaluation of the left operand.

First, a is incremented. Then the arguments to f are evaluated there are zero of them. Then there is a sequence point before f is actually called. So, we see that our program is standard-conforming. Notice that the above argument does not actually depend on the details of the body of the function f. It only depends on the function containing something ending in a sequence point — in our example this is a return statement, but an expression statement or a full declarator would do just as well.

If the left-hand operand is evaluated first, foo returns 6. Otherwise, it returns The C standard does not specify in which order the operands should be evaluated, and also does not require an implementation either to document the order or even to stick to one order. The effect of this code is unspecified , meaning that one of several specific things will happen, but the C standards do not say which. When a signal is received, this will happen between sequence points.

Side effects on volatile objects prior to the previous sequence point will have occurred, but other updates may not have occurred yet. The C standard is quite restrictive about what data access can occur within a signal handler. The POSIX standard also allows a small number of library functions to be called from a signal handler.

These functions are referred to as the set of async-signal-safe functions. If your program is intended to run on a POSIX system but not on other systems, you can safely call these from your signal handler too. You write statements to cause actions and to control flow within your programs.

You can also write statements that do not do anything at all, or do things that are uselessly trivial. You can use labels to identify a section of source code for use with a later goto see The goto Statement. A label consists of an identifier such as those used for variable names followed by a colon.

GCC will compile code that does not meet this requirement, but be aware that if you violate it, your code may have portability issues.

You can turn any expression into a statement by adding a semicolon to the end of the expression. In each of those, all that happens is that each expression is evaluated. However, they are useless because they do not store a value anywhere, nor do they actually do anything, other than the evaluation itself.

The compiler is free to ignore such statements. Expression statements are only useful when they have some kind of side effect, such as storing a value, calling a function, or this is esoteric causing a fault in the program.

Here are some more useful examples:. You can use the if statement to conditionally execute part of your program, based on the truth value of a given expression. Here is the general form of an if statement:. If test evaluates to true, then then-statement is executed and else-statement is not. If test evaluates to false, then else-statement is executed and then-statement is not.

The else clause is optional. You can use the switch statement to compare one expression with others, and then execute a series of sub-statements based on the result of the comparisons.

Here is the general form of a switch statement:. The switch statement compares test to each of the compare expressions, until it finds one that is equal to test. Then, the statements following the successful case are executed. All of the expressions compared must be of an integer type, and the compare-N expressions must be of a constant integer type e.

Optionally, you can specify a default case. Notice the usage of the break statement in each of the cases. This is because, once a matching case is found, not only are its statements executed, but so are the statements for all following cases:. This is often not desired. Including a break statement at the end of each case redirects program flow to after the switch statement.

As a GNU C extension, you can also specify a range of consecutive integer values in a single case label, like this:. This has the same effect as the corresponding number of individual case labels, one for each integer value from low to high , inclusive. Be careful to include spaces around the For example, write this:.

It is common to use a switch statement to handle various possible values of errno. The while statement is a loop statement with an exit test at the beginning of the loop. Here is the general form of the while statement:.

The while statement first evaluates test. If test evaluates to true, statement is executed, and then test is evaluated again. The do statement is a loop statement with an exit test at the end of the loop.

Here is the general form of the do statement:. The do statement first executes statement. After that, it evaluates test. If test is true, then statement is executed again. The for statement is a loop statement whose structure allows easy variable initialization, expression testing, and variable modification.

It is very convenient for making counter-controlled loops. Here is the general form of the for statement:. The for statement first evaluates the expression initialize. Then it evaluates the expression test. If test is false, then the loop ends and program control resumes after statement.

Otherwise, if test is true, then statement is executed. Finally, step is evaluated, and the next iteration of the loop begins with evaluating test again. Here is another example that prints the integers from zero through nine:.

First, it evaluates initialize , which assigns x the value 0. Then, as long as x is less than 10, the value of x is printed in the body of the loop. Then x is incremented in the step clause and the test re-evaluated.

All three of the expressions in a for statement are optional, and any combination of the three is valid. Since the first expression is evaluated only once, it is perhaps the most commonly omitted expression.

You could also write the above example as:. In this example, x receives its value prior to the beginning of the for statement. If you leave out the test expression, then the for statement is an infinite loop unless you put a break or goto statement somewhere in statement.

This is like using 1 as test ; it is never false. This for statement starts printing numbers at 1 and then continues indefinitely, always printing x incremented by If you leave out the step expression, then no progress is made toward completing the loop—at least not as is normally expected with a for statement. Perhaps confusingly, you cannot use the comma operator see The Comma Operator for monitoring multiple variables in a for statement, because as usual the comma operator discards the result of its left operand.

This loop:. Here is an example of a function that computes the summation of squares, given a starting integer to square and an ending integer to square:.

A block is a set of zero or more statements enclosed in braces. Blocks are also known as compound statements. Often, a block is used as the body of an if statement or a loop statement, to group statements together. You can declare variables inside a block; such variables are local to that block.

In C89, declarations must occur before other statements, and so sometimes it is useful to introduce a block simply for this purpose:. A null statement does not do anything. It does not store a value anywhere. It does not cause time to pass during the execution of your program. Most often, a null statement is used as the body of a loop statement, or as one or more of the expressions in a for statement. Here is an example of a for statement that uses the null statement as the body of the loop and also calculates the integer square root of n , just for fun :.

Here is another example that uses the null statement as the body of a for loop and also produces output:. A null statement is also sometimes used to follow a label that would otherwise be the last thing in a block. You can use the goto statement to unconditionally jump to a different place in the program. Here is the general form of a goto statement:. You have to specify a label to jump to; when the goto statement is executed, program control jumps to that label.

See Labels. The label can be anywhere in the same function as the goto statement that jumps to it, but a goto statement cannot jump to a label in a different function. You can use goto statements to simulate loop statements, but we do not recommend it—it makes the program harder to read, and GCC cannot optimize it as well.

You should use for , while , and do statements instead of goto statements, when possible. Here is a contrived example:. You can use the break statement to terminate a while , do , for , or switch statement. That example prints numbers from 1 to 7. If you put a break statement inside of a loop or switch statement which itself is inside of a loop or switch statement, the break only terminates the innermost loop or switch statement.

You can use the continue statement in loops to terminate an iteration of the loop and begin the next iteration. If you put a continue statement inside a loop which itself is inside a loop, then it affects only the innermost loop. You can use the return statement to end the execution of a function and return program control to the function that called it.

Here is the general form of the return statement:. You can, however, use the return statement without a return value. In that case, the function cosine was called in a context that required a return value, so the value could be assigned to x. Even in contexts where a return value is not required, it is a bad idea for a non- void function to omit the return value. With GCC, you can use the command line option -Wreturn -type to issue a warning if you omit the return value in such functions.

Here are some examples of using the return statement, in both a void and non- void function:. You can use the typedef statement to create new names for data types. Here is the general form of the typedef statement:. Creating this new name for the type does not cause the old name to cease to exist. In the case of custom data types, you can use typedef to make a new name for the type while defining the type:. To make a type definition of an array, you first provide the type of the element, and then establish the number of elements at the end of the type definition:.

You can write functions to separate parts of your program into distinct subprocedures. To write a function, you must at least create a function definition. Every program requires at least one function, called main. A function declaration ends with a semicolon. Here is the general form:. A typical parameter consists of a data type and an optional name for the parameter. You can also declare a function that has a variable number of parameters see Variable Length Parameter Lists , or no parameters using void.

Leaving out parameter-list entirely also indicates no parameters, but it is better to specify it explicitly with void. The parameter names in the declaration need not match the names in the definition. You should write the function declaration above the first use of the function.

Within an expression, higher precedence operators will be evaluated first. C - Operators Advertisements. Previous Page. Next Page.

Previous Page Print Page. Save Close. Checks if the values of two operands are equal or not. If the values are not equal, then the condition becomes true. Checks if the value of left operand is greater than the value of right operand. If yes, then the condition becomes true. Checks if the value of left operand is less than the value of right operand. Checks if the value of left operand is greater than or equal to the value of right operand. Checks if the value of left operand is less than or equal to the value of right operand.

Called Logical AND operator. If both the operands are non-zero, then the condition becomes true. Called Logical OR Operator. If any of the two operands is non-zero, then the condition becomes true. It is used to reverse the logical state of its operand. If a condition is true, then Logical NOT operator will make it false. Binary One's Complement Operator is unary and has the effect of 'flipping' bits.

Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand.



0コメント

  • 1000 / 1000