C_OPERATORS
Demonstrate C Operators
C_OPERATORS
is a C program which
demonstrates the use of the built-in operators in C.
In C, operators include the arithmetic operators:
-
+, for addition;
-
-, for subtraction;
-
*, for multiplication;
-
/, for division (real and integer versions);
-
%, for the remainder.
the bit operators:
-
<<, the left shift operator, which multiplies by powers of 2;
-
>>, the right shift operator, which divides by powers of 2;
-
&, the bitwise AND;
-
|, the bitwise OR;
-
^, the bitwise exclusive OR;
-
~, the ones complement;
the logical operators (note that there is no "exclusive OR" operator):
-
!, the logical negation;
-
&&, the logical AND;
-
||, the logical OR.
the increment operators:
-
++, increments by 1;
-
--, decrements by 1;
Licensing:
The computer code and data files described and made available on this
web page are distributed under
the GNU LGPL license.
Languages:
C_OPERATORS is available in
a C version.
Related Data and Programs:
C_INTRINSICS,
a C program which
illustrates the use of intrinsic functions supplied by the C language.
Reference:
-
Samuel Harbison, Guy Steele,
C: A Reference Manual,
Third Edition,
Prentice Hall, 1991,
ISBN: 0-13-110933-2,
LC: QA76.73.C15H38.
-
Brian Kernighan, Dennis Ritchie,
The C Programming Language,
Second Edition,
Prentice Hall, 1988,
ISBN: 0-13-110362-8,
LC: QA76.73C15.K47.
Source Code:
List of Routines:
-
MAIN is the main program for C_OPERATORS.
-
TEST_AMP demonstrates &.
-
TEST_AMPAMP demonstrates &&.
-
TEST_BANG demonstrates !.
-
TEST_BAR demonstrates |.
-
TEST_BARBAR demonstrates ||.
-
TEST_CARET demonstrates ^.
-
TEST_LSHIFTLSHIFT demonstrates <<.
-
TEST_MINUS demonstrates -.
-
TEST_PLUS demonstrates +.
-
TEST_PLUSPLUS demonstrates ++.
-
TEST_RSHIFTRSHIFT demonstrates >>.
-
TEST_SLASH demonstrates /.
-
TEST_STAR demonstrates *.
-
TEST_TWIDDLE demonstrates ~.
-
TIMESTAMP prints the current YMDHMS date as a time stamp.
You can go up one level to
the C source codes.
Last revised on 28 May 2012.