Skip to main content

Posts

Showing posts with the label Operators in C Programming

Operators in C programming : Bitwise Operators

Bitwise Operator are used for manipulating data at bit level. These operators are used for testing the bits, or shifting them right or left. Bitwise The most common used unary operator is unary minus, where a numerical constant, variable expression is preceded by a minus sign. Unary minus operator is distinctly different from the arithmetic operator which denotes subtraction ( - ). The subtraction operator requires two separate operands. Several examples of unary minus operator -743                 - 0X7FFF                    -0.2                 -5E-8 -r00+1             - (x+y)                 ...

Operators in C programming : Conditional Operators

  The operator ?: is known as conditional operator. Simple conditional operations can be carried out with conditional operator. An expression that make use of the conditional operator is called a conditional expression. Such an expression can be written in place of traditional ifelse statement. A conditional expression is written in the form: expression1 ? expression2 : expression3 When evaluating a conditional expression, expression1 is evaluated first. If expression1 is true, the value of expression2 is the value of conditional expression. If expression1 is false, the value of expression3 is the value of conditional expression. For example: a = 10 ; b = 15 ; x = (a > b) ? a : b ; In this example, x will be assigned the value of b. This can be achieved by using the if_else statement as follows: if (a<b) x = a ; else x = b ;

Operators in C programming : Special Operators

C supports some special operators such as comma operator, size of operator, pointer operator (* and &) and member selection operators. (.and  →) Comma Operator: The comma operator can be used to link the related expression together. Comma linked lists of expression are evaluated left to right and the value of right-most expression is the value of combined expression. For example, value = (x = 10, y = 5, x + y), Here, 10 is assigned to x and 5 is assigned to y and so expression x+y is evaluated as (10+5) i.e. 15. Size of Operator: The size of operator is used with an operand to return the number of bytes it occupies. It is a compile time operand. The operand may be a variable, a constant or a data type qualifier. The associativity of size of right to left. For example Suppose that i is an integer variable, x is a floating-point variable, d is double-precision variable and c is character type variable. The statements: printf (“integer : %d \n”, size of i) ; ...

Operators in C programming : Assignment Operators

There are several different assignment operators in C. All of them are used to form assignment expressions which assign the value of an expression to an identifier. The most commonly used assignment operator is =. Assignment expressions that make use of the operator are written in the form: identifier = expression Where identifier generally represents a variable, and expression represents a constant, a variable or more complex expression.  Here are some typical assignment expressions that make use of the = operator. a = 3 x = y delta = 0.001 sum = a+b area = length * width Assignment operator = and equality operator = = are distinctly different. The assignment operator can be applied only to integer type signed or unsigned) and not to float or double. They are Operator                    Meaning &            ...

Operators in C programming : Logical operators

Operator                    Meaning &&                              And ||                                    Or !                                    Not Logical operators are used to compare & evaluate logical and relational expressions. Operator && is referred as logic and, the operator || is referred as logic or. The result of a logic and operation will be true only if both operands a...

Operators in C Programming : Unary Operators

C includes a class of operators that act upon a single operand to produce a new value. Such operators k/a unary operators. Unary operators usually precede their single operands, though some unary operators are written after their operands.* There are two other type of unary operator also available in C: 1. Increment Operator (+ +) 2. Decrement Operator (- - ) The increment operator causes its operand to be increased by 1 where as the decrement operator causes its operand to be decreased by 1. The operand used with each of these operators must be a single variable.

Operators in C Programming : Relational and Logical Operators

Relational Operators are those that are used to compare two similar operands, and depending on their relation take some actions. The relational operators in C are listed as Operators                   Meaning <                                  less than <=                                less than or equal to >                                  greater than >=       ...

Operators in C Programming : Arithmetic Operators

There are five arithmetic operators in C. They are Operators                               Purposes      +                                         Addition      -                                          Subtraction      *                           ...