Write down a c++ program to input length and breadth of a rectangle, display the area and
perimeter?
Answers
Explanation:
Program to implement Logic Gates
A Logic gate is an elementary building block of any digital circuits. It takes one or two inputs and produces output based on those inputs. Outputs may be high (1) or low (0). Logic gates are implemented using diodes or transistors. It can also be constructed using vacuum tubes, electromagnetic elements like optics, molecule etc. In a computer, most of the electronic circuits are made up logic gates. Logic gates are used to create a circuit that performs calculations, data storage or shows off object-oriented programming especially the power of inheritance.
There are seven basic logic gates defined, these are:
AND gate,
OR gate,
NOT gate,
NAND gate,
NOR gate,
XOR gate and
XNOR gate.
Below are the brief details about them along with their implementation:
AND Gate
The AND gate gives an output of 1 if both the two inputs are 1, it gives 0 otherwise.
Answer:
#include<iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;
int main()
{
int length, breadth, area,peri;
cout << "\nEnter the Length of Rectangle : ";
cin>>length;
cout << "\nEnter the Breadth of Rectangle : ";
cin>>breadth;
area = length * breadth;
cout << "\nArea of Rectangle : " << area;
peri=2*(length+breadth);
cout << "\nPerimeter of Rectangle : " << peri;
}