Answer to Question #186481 in C for bullock

Question #186481

Write down the Boolean Table AND the Boolean Expression that models

the circuit that engineers two light switches A and B at the two EXITS

of a huge conference center. The specifications are as follows: (a)

Both light switches operate the one common light in the room.


(b) The light is off when both switches A and B are OFF. That would

mean that A = B = 0 implies the light is OFF = 0.


(c) Flipping either switch will turn the light ON = 1.


(d) Following (c) flipping either switch will turn the light OFF = 0.


(e) We can go back and forth between (c) and (d). Flipping either

switch A or B will turn the light OFF = 0 if it is ON = 1 and ON = 1

if it is OFF = 0. 


1
Expert's answer
2021-04-28T04:24:59-0400

The proposed logic can be implemented by using the EX-OR gate boolean logic. The truth table is given below:

A B A EX-OR B Light Status

0 0 0 OFF

0 1 1 ON

1 0 1 ON

0 0 0 OFF


#include <stdlib.h> 
#include <stdio.h>
#include <conio.h>

main(void)
{
	int A, B,Status;
	int Flag=1;
	while(Flag)
	{
		A=-1; 
		while(A<0 || A>1)	{printf("\nEnter Swtich Status - A: "); scanf("%d",&A);}
		B=-1; 
		while(B<0 || B>1)	{printf("\nEnter Swtich Status - B: "); scanf("%d",&B);}
		Status = A^B;
		printf("\n\nSwithc and Light Status:\tA\tB\tA EXOR B\tLight Status");
		if(Status) printf("\n\t\t\t\t%d\t%d\t   %d\t\t  ON",A,B,Status);
		else	   printf("\n\t\t\t\t%d\t%d\t   %d\t\t  OFF",A,B,Status);
		printf("\n\nPress 1 to continue or 0 to quit: "); scanf("%d",&Flag);
		
	}
	
}





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS