×

Close

- Computer Organisation and Architecture - COA
- Practical
**231 Views**- 3 Offline Downloads
- Uploaded 2 months ago

Government Polytechnic Muzaffarpur. Name of the Lab: Computer Organization & Architecture Practical: Computer Organization &Architecture Subject Code: 1618308 1. Write a program in C-language to implement the digital gates. The program should give the truth table of the gate, which is selected by the user from the menu displayed by the program. #include<stdio.h> int And(int a, int b); int Or(int a, int b); int Not(int a); void main() { ///where main body of code will go } int And(int a, int b) { int output; if(a==0 && b==0) output=0; if(a==1 && b==0) output=0; if(a==0 && b==1) output=0; if(a==1 && b==1) output=1; return (output); } int Or(int a, int b) {

int output; if(a==0 && b==0) output=0; if(a==1 && b==0) output=1; if(a==0 && b==1) output=1; if(a==1 && b==1) output=1; return (output); } int Not(int a) { int output; if(a==0 ) output=1; if(a==1 ) output=0; return (output); } Logic gates Digital systems are said to be constructed by using logic gates. These gates are the AND, OR, NOT, NAND, NOR, EXOR and EXNOR gates. The basic operations are described below with the aid of truth tables. AND gate

The AND gate is an electronic circuit that gives a high output (1) only if all its inputs are high. A dot (.) is used to show the AND operation i.e. A.B. Bear in mind that this dot is sometimes omitted i.e. AB OR gate The OR gate is an electronic circuit that gives a high output (1) if one or more of its inputs are high. A plus (+) is used to show the OR operation. NOT gate The NOT gate is an electronic circuit that produces an inverted version of the input at its output. It is also known as an inverter. If the input variable is A, the inverted output is known as NOT A. This is also shown as A', or A with a bar over the top, as shown at the outputs. The diagrams below show two ways that the NAND logic gate can be configured to produce a NOT gate. It can also be done using NOR logic gates in the same way.

2. Write a program in C-language to implement division algorithm. #include <stdio.h> int main(){ int dividend, divisor, quotient, remainder; printf("Enter dividend: "); scanf("%d", ÷nd); printf("Enter divisor: "); scanf("%d", &divisor); // Computes quotient quotient = dividend / divisor; // Computes remainder remainder = dividend % divisor; printf("Quotient = %d\n", quotient); printf("Remainder = %d", remainder); return 0; }

## Leave your Comments