Exp 4
Exp 4
A multiplexer is a combinational circuit that has 2n input lines and a single output line.
The multiplexer is a multi-input and single-output combinational circuit. The binary
information is received from the input lines and directed to the output line. On the basis
of the values of the selection lines, one of these data inputs will be connected to the
output..
C++ Code:
#include <iostream>
using namespace std;
return 0;
}
#include <iostream>
int mux8to1(int s2, int s1, int s0, int d0, int d1, int d2, int d3, int d4, int d5, int d6, int d7) {
int select = (s2 << 2) | (s1 << 1) | s0; // Convert selector bits to decimal
switch (select) {
int main() {
int d0 = 10, d1 = 20, d2 = 30, d3 = 40, d4 = 50, d5 = 60, d6 = 70, d7 = 80; // Data inputs
if ((s2 < 0 || s2 > 1) || (s1 < 0 || s1 > 1) || (s0 < 0 || s0 > 1)) {
cout << "Invalid selector inputs! Enter only 0 or 1." << endl;
return 1;
int output = mux8to1(s2, s1, s0, d0, d1, d2, d3, d4, d5, d6, d7);
// Display output
return 0;