/*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)

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?

Member Avatar for v3ga

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;
}

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

Member Avatar for v3ga

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

Member Avatar for v3ga

Mark solved if its solved pls

thanks .....

I HAVE THIS PROBLEM AND I DON'T KNOW HOW TO SOLVE IT

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.