What is Left Shift Operator in C?

What is Left Shift Operator in C?
The Left Shift Operator operates on the binary bits. Because the left shift operator is a binary operator, we'll need two operands to shift the bits to the left side and add zeroes to the space on the right side once they've been shifted. It is denoted by the << sign.
Syntax
The left shift operator's result will be the same as multiplying varName by .
Example
As we can see in the example above, multiplying 100 by equals 800.
Transform Your Career
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
What Is The Use of Left Shift Operator in C?
We use the left shift operator to move the bits of available values to the left. It performs this by putting zeros on the right side of the value in the empty spaces created by shifting. Based on the number of positions specified by the second operand, it shifts the bits available for the first operand to the left.
How Left Shift Operator Works in C?
To use a left shift operator, we need two operands. The integer type should be used for both operands of the left shift operator. The first operand's bits are shifted to the left by the number of places given by the second operand. Simultaneously, the zeroes are placed into the empty spaces generated by the bits shifted to the left. The bits shifted to the end, including the sign bit, are discarded.
Examples to Implement Left Shift Operator in C
Output:
Example Showing Left Shift Operation Performed on Two Positive Operands
Output:
Turn Learning into Career Growth
Example Showing A Scenario When The Value of Second Operand Is Negative
Output:
Scaler Placement Report and Statistics
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
Example Showing Scenario When The Value of First Operand Is Negative
Output:
Example Showing Scenarios When Number of Positions to be Shifted Is Zero and Greater Than The Size of Integer
Output:
Program to Use The Left Shift Operator on the unsigned int Data-type.
Output:
Undefined Result Of Operator
The following are some examples of undefined results from left shift operations:
- If the first available operand is negative, the result of the left shift operation will be undefined.
- In a similar scenario, if the second operand's value is negative, the result is also undefined.
- Furthermore, we get undefined results when the second operand's value is equal to or larger than the total number of bits contained in the first operand.

As you can see in the diagram above, shifting the number one position to the left often results in the output being . All bits in this example changed to the left after we performed the left shift operation on the binary value. The resulting space is now filled with zeros (0).
In the above example, and . As a result, the result produced from , i.e. , will be , which is .
Learn More
Learn more about bitwise shift operator in C.
Scaler Placement Report and Statistics
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
Conclusion
- We have discussed the left shift operator in C.
- We have discussed three different aspects of left shift operator in C.
- We covered some examples to understand the left shift operator in C.
- We have also covered how the left shift operator works in C.