0

/*CODING A PROGRAM FOR LOGIC GATES*//
#include<stdio.h>
#include<conio.h>

int x,y,z;
//printf("Enter value of x");
scanf("x:",&x);
//printf("Enter value of y");
scanf("y:",&y);
And(int,int)
if(x==1&&y==1)
 printf("z=1");
else
printf("z=0");
Or
if(x=0&&y==0)
printf("z=0")
else
printf("z=1");
Not
if(x==0)
 printf(z=1)
else
 printf(z=0)
4
Contributors
7
Replies
18
Views
5 Years
Discussion Span
Last Post by sofoklis
0

So....

is there a specific error you want to tell?
are you asking us for suggestions or instructions?
Are you unsure of what to do next?
or maybe the code doesn't give the correct output?

0

The way u use scanf is wrong. Look up format specifier.
Accept x & y just print x||y, X&&y, !x

#include<stdio.h>

int main()
{
	int x,y,orxy,andxy,notx;
	
	printf("\nEnter x&y");
	scanf("%d%d",&x,&y);
	orxy=x||y;
	andxy=x&&y;
	notx=!x;
	printf("\nOR:%d\nAND:%d\nNOT(x):%d",orxy,andxy,notx);
	return 0;
}
0

if(x=0&&y==0)

In line 12 use == in x to check if the values are the same

@v3ga
don't do the OP's work for him it's not your homework

0

Sorry, but it was not like he did no work. He had some code and I was just suggesting an alternative way.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.