Wednesday, July 10, 2013

One's Complement Operator in C

This operator is a unary operator. It just takes one value and performs one's complement on the number.

For example,
x=~3;
It takes the binary representation of the 3,
3 - 0011

Tuesday, July 9, 2013

Bit-wise Operators in C

Bit-wise operators are used to perform operations on the binary value of the number. These operators can be applied only on the Integral data types i.e., short, int, long, and also on char, as it can be converted to corresponding ASCII.

These operators are used for bit-manipulation in C. Bit manipulation is done on the numbers, whether they are signed or not. There are six bit-wise operators in C. The following table gives you description of the operators.

Logical Operators in C

Logical Operators are used to perform some logical operations in C. Sometimes, we need to use more than one relational operator in C. In such cases we use this kind of logical operators to connect the relational operators.

There are three logical operators. The following table gives a description of the logical operators.

Relational Operators in C

Relational Operators are those operators, which are used to find the relation between two operands. In C we need to perform some operations to know the relation between the operands, such operators are listed under the relational operators. When we use such a operator, the result gives out to be either 1 or 0 i.e., true or false.

The below table gives a list of relational operators which we use in C.

Monday, July 8, 2013

Assigning float value to int type

In general, if we assign the integer value to the float type, it automatically converts the type to float by just adding the decimal points.

For example,
float a=3;
It takes the value as 3.000000. You can understand this by referring to the concept of Type casting by clicking here.

But what happens if we assign float to int? Does it give an error? Let us check it now.

Type Casting in C

Type Casting is nothing converting one data type value into another data type value. In C, we do have type casting where in we can convert a data type into another data type. Based on the type of conversion, we have two types of conversion.

  1. Implicit
  2. Explicit
Both these conversions are for converting one data type value into another data type but the difference lies with, whether we mention to convert or it automatically converts. Lets get more briefly into the topic.

Operator Precedence in C

In C, we perform many operations. In such operations, generally we come across a problem or ambiguity. Ambiguity means possibility of getting different answers for the same expression. We can clearly understand what is ambiguity by observing the following example,
x=3+4*5;
So, what would be the answer to the above equation. Let us solve the same equation in two different ways.