You are on page 1of 4

ASSIGNMENT # 2

Name:
Hafiz Muzammal Ahmad

Reg No:
FA22-BSE-011

Submitted To:
Dr Misbah

Subject:
Discrete Structure

CUI
(Sahiwal Campus)
USE OF GATES IN HARDWARE:-
To build digital circuitry, logic gates are a necessary
component. They perform logical processes that are
crucial for digital circuits at the very least. In most of the
electrical devices we use today, logic gates are present.
Uses in Software:-
Software uses AND gates for programming and
developing methods.
Programming AND gates may be used to control the flow
of processes.
Software AND gates are used to implement boolean logic
operations like AND, NAND, and XOR. These techniques
are often applied in the development of algorithms.
Computer software uses AND gates to carry out bit-wise
operations. These procedures are often used in low-level
programming as well as system programming.
Summary:
Control flow, Boolean logic, bit manipulation, and system
programming are all performed via logic gates, which are
also utilised to build digital circuits.
THE FOLLOWING IS THE EXAMPLE OF THE CODE IN
C++ USING THE LOGICAL OPERATORS
CODE:-
#include <iostream>
using namespace std;
int main() {
int age = 25;
bool is_student = false;

if (age < 18) {


cout << "You are not eligible to vote." << endl;
} else if (age >= 18 && age <= 65) {
cout << "You are eligible to vote." << endl;
} else if (age > 65) {
cout << "You are eligible to vote, but you are retired."
<< endl;
}

if (age < 18 || is_student) {


cout << "You are not eligible to work." << endl;
} else {
cout << "You are eligible to work." << endl;
}

return 0;
}
Output:
You are eligible to vote.
You are eligible to work.

--------------------------------
Process exited after 0.0367 seconds with return value 0
Press any key to continue . . .

You might also like