Course Content
Detailed Content of Programming in C
0/1
Introduction
0/1
Structure of C program
0/1
Answers of ‘C’ Pointers Programs
0/1
About Lesson

Write a program that takes two integers as input, performs bitwise AND, OR, and XOR operations, and displays the results.

#include <stdio.h>

int main() {
// Declare variables
int num1, num2;

// Input: Get two integers from the user
printf(“Enter the first integer: “);
scanf(“%d”, &num1);

printf(“Enter the second integer: “);
scanf(“%d”, &num2);

// Process and Output: Perform bitwise AND, OR, and XOR operations
printf(“Bitwise AND: %d & %d = %dn”, num1, num2, num1 & num2);
printf(“Bitwise OR : %d | %d = %dn”, num1, num2, num1 | num2);
printf(“Bitwise XOR: %d ^ %d = %dn”, num1, num2, num1 ^ num2);

return 0; // Exit the program successfully
}