C Exercises: Shift the specified data by two bits to the left
C Basic Declarations and Expressions: Exercise-56 with Solution
Write a C program to shift given data by two bits to the left.
Sample Solution:
C Code:
#include<stdio.h>
int main() {
int a, b;
// Prompt user to input an integer
printf("Read the integer from keyboard-");
scanf("%d",&a);
// Display the original integer value
printf("\nInteger value = %d ",a);
// Left shift 'a' by 2 bits and assign it to 'b'
a <<= 2;
b = a;
// Display the left shifted data
printf("\nThe left shifted data is = %d ",b);
return 0;
}
Sample Output:
Read the integer from keyboard- Integer value = 2 The left shifted data is = 8
Flowchart:

C programming Code Editor:
Previous: Write a C program that swaps two numbers without using third variable.
Next: Write a C program to reverse and print a given number.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join