Features of C Language
Features of C Language
C is the widely used language. It provides a lot of features that are given below.
1. Simple 2. Machine Independent or Portable 3. Mid-level programming
language
4. structured programming language 5. Rich Library 6. Memory Management
7. Fast Speed 8. Pointers 9. Recursion 10. Extensible
1. Simple:
C is a simple language in the sense that it provides structured approach (to break the
problem into parts)
2. Machine Independent or Portable:
C Programs can be executed in many machines with little bit or no change.
3. Mid-level Prorgramming language:
C is also used to do low level programming. It also supports the feature of high
level language. That is why it is known as mid-level language.
4. Structured prorgramming language:
C is a structured programming language in the sense that we can break the program
into parts using functions.
5. Rich Library:
C provides a lot of inbuilt functions that makes the development fast.
6. Memory Management:
It supports the feature of Dynamic Memory Allocation.
7. Speed:
The compilation and execution time of C language is fast.
8. Pointers:
C provides the feature of pointers. We can directly interact with the memory by using the
pointers. We can use pointers for memory, structures, functions, array etc.
9. Recursion:
In c, we can call the function within the function.
10. Extensible:
C language is extensible because it can easily adopt new features.
DATA TYPES IN C:
A data type specifies the type of data that a variable can store such as integer, floating,
character etc.
1. Arithmetic Operators:
Arithmetic operators performs basic arithmetic operations like Addition, Subtraction,
Multiplication, Division and Modulus division etc., Assume variable a holds 10 and variable b holds
20, then:
S.No. Operato
Description Example
r
1. + Addition - Adds values on either side of the operator a + b will give 30
Subtraction - Subtracts right hand operand from left
2. - a - b will give -10
hand operand
Multiplication - Multiplies values on either side of the
3. * a * b will give 200
operator
Division - Divides left hand operand by right hand
4. / b / a will give 2
operand
Modulus - Divides left hand operand by right hand
5. % b % a will give 0
operand and returns remainder
6. ++ (Increment)- Increases an integer value by one A++ will gives 11
7 -- (Decrement) - Decreases an integer value by one A-- will gives 9
3. Logical Operators:
C Language supports the following logical operators – Logical Operators are used to
combine two or more Relational expressions in to a Logical expression. These Logical expressions
produce either True or False. Assume variable A holds 10 and B holds 20, then –
S.No Operator and Description
&& (Logical AND) If both the operands are non-zero, then the condition becomes true. Ex:
1
(A && B) is true.
|| (Logical OR) If any of the two operands are non-zero, then the condition becomes true. Ex:
2
(A || B) is true.
! (Logical NOT) Reverses the logical state of its operand. If a condition is true, then the
3
Logical NOT operator will make it false. Ex: !(A && B) is false.
4. BITWISE OPERATORS:
Bitwise Operators are used to perform operations on Bits and Bytes, these operations are
called Boolean Operations. C Language supports the following Bitwise Operators −Assume variable
A holds 2 and B holds 3, then
S.N Operator and Description
o
& (Bitwise AND) It performs a Boolean AND operation on each bit of its integer arguments. Ex: (A &
1
B) is 2.
| (BitWise OR) It performs a Boolean OR operation on each bit of its integer arguments. Ex: (A | B) is
2
3.
^ (Bitwise XOR) It performs a Boolean exclusive OR operation on each bit of its integer arguments.
3 Exclusive OR means that either operand one is true or operand two is true, but not both. Ex: (A ^ B) is
1.
~ (Bitwise Not) It is a unary operator and operates by reversing all the bits in the operand. Ex: (~B)
4
is -4.
5 << (Left Shift) It moves all the bits in its first operand to the left by the number of places specified in
the second operand. New bits are filled with zeros. Shifting a value left by one position is equivalent to
multiplying it by 2, shifting two positions is equivalent to multiplying by 4, and so on. Ex: (A << 1) is 4.
>> (Right Shift) Binary Right Shift Operator. The left operand’s value is moved right by the number of
6
bits specified by the right operand. Ex: (A >> 1) is 1.
>>> (Right shift with Zero) This operator is just like the >> operator, except that the bits shifted in
7
on the left are always zero. Ex: (A >>> 1) is 1.
5. ASSIGNMENT OPERATORS:
C Language supports the following assignment operators −
S.No Operator and Description
= (Simple Assignment ) Assigns values from the right side operand to the left side operand Ex: C = A
1
+ B will assign the value of A + B into C
+= (Add and Assignment) It adds the right operand to the left operand and assigns the result to the
2
left operand. Ex: C += A is equivalent to C = C + A
−= (Subtract and Assignment)It subtracts the right operand from the left operand and assigns the
3
result to the left operand. Ex: C -= A is equivalent to C=C–A
*= (Multiply and Assignment) It multiplies the right operand with the left operand and assigns the
4
result to the left operand. Ex: C *= A is equivalent to C = C * A
/= (Divide and Assignment) It divides the left operand with the right operand and assigns the result
5
to the left operand. Ex: C /= A is equivalent to C = C / A
%= (Modules and Assignment) It takes modulus using two operands and assigns the result to the
6
left operand. Ex: C %= A is equivalent to C = C % A