Bitwise Operators - Basic C Programs - C Programming: C Program to demonstrate bitwise operators
C Program to demonstrate bitwise operators.
/* Program to demonstrate bitwise operator */
#include <stdio.h>
#include<conio.h>
void main()
{
char c1, c2, c3; /* Local definitions */
/* Statements */
clrscr();
printf("ENTER VAULES OF c1 and c2 : ");
scanf("%c, %c", &c1, &c2);
c3 = c1 & c2; /* & is a bitwise AND */
printf("\n Bitwise AND i.e. cl & c2 = %c",c3);
c3 = c1 | c2; /* | is a bitwise OR */
printf("\n Bitwise OR i.e. c1 | c2 = %c", c3);
c3 = cl ^ c2; /* ^ is a bitwise XOR */
printf("\n Bitwise XOR i.e. cl^ c2 = %c", c3);
c3 = ~cl; /*~ is a one's complement */
printf("\n ones compliment of c1 = %c", c3);
c3 = cl<<2; /* << is a shift left */
printf("\n Left shift by 2 bits c1 << 2 = %c",c3);
c3 = cl>>2; /* >> is a shift right */
printf("\n Right shift by 2 bits c1 >> 2 =%c",c3);
getch();
} /* main *
OUTPUT:
ENTER VAULES OF cl and c2: 23 67
Bitwise AND i.e. cl & c2 = ?
Bitwise OR i.e. cl | c2 = -
Bitwise XOR i.e. c1^c2 = t
ones compliment of cl = -
Left shift by 2 bits cl << 2 = +
Right shift by 2 bits cl >> 2 = ?
EXPLANATION: This program prints the result of bitwise operations between two operands cl and c2, which are inputting by the user.
Computer Programming C Laboratory: Basic C Programs : Tag: C Programming : - C Program to demonstrate bitwise operators (Bitwise Operators)
Computer Programming C Laboratory
CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
English Essentials I
EN25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
தமிழர் மரபு - Heritage of Tamils
UC25H01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Calculus
MA25C01 Maths 1 M1 - 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Physics I
PH25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Chemistry I
CY25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Makerspace
ME25C04 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Computer Programming C
CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Computer Programming Python
CS25C02 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Fundamentals of Electrical and Electronics Engineering
EE25C03 1st Semester EEE Depart | 2025 Regulation | 1st Semester 2025 Regulation
Introduction to Mechanical Engineering
ME25C03 1st Semester Mechanical Dept | 2025 Regulation | 1st Semester 2025 Regulation
Introduction to Civil Engineering
CE25C01 1st Semester Civil, Agri Departments | 2025 Regulation | 1st Semester 2025 Regulation
Essentials of Computing
CS25C03 1st Semester - AIDS, CSE, CSE(CY), IT Department | 2025 Regulation | 1st Semester 2025 Regulation
Applied Physics I Laboratory
PH25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Applied Chemistry I Laboratory
CY25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Computer Programming C Laboratory
CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Computer Programming Python Laboratory
CS25C02 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Engineering Drawing
ME25C01 EEE, Mech, Agri, EEE Depts | 2025 Regulation | 2nd Semester 2025 Regulation
Basic Electronics and Electrical Engineering
EE25C04 1st Semester ECE Dept | 2025 Regulation | 1st Semester 2025 Regulation
Essentials of Computing - Laboratory
CS25C03 1st Semester AIDS, CSE, CSE(CY), IT Depts | practical Laboratory Manual | 2025 Regulation | 1st Semester 2025 Regulation