hey
i have a project on logic circuit simulation.i don't know how to include basic gate images in my code,so that it is displayed with the chosen gates output.i have jgrasp c_compiler.so plz help me out.
#include<stdio.h>
int And(int a, int b);
int Or(int a, int b);
int Not(int a);
int Nand(int ,int );
int Xor(int ,int );
int Nor(int ,int );
main()
{
int ch,k,l,m,a,b,p,n,r;
do
{
printf("1.And,2.Or,3.Not,4.Xor,5.Nand,6.Nor,7.Exit\n");
scanf("%d",&ch);
switch(ch)
{
case 1:printf("Enter value of a&b");
scanf("%d %d",&a,&b);
k=And(a,b);
printf("%d\n",k);
break;
case 2:printf("Enter value of a&b");
scanf("%d %d",&a,&b);
l=Or(a,b);
printf("%d\n",l);
break;
case 3:printf("Enter value of a&b");
scanf("%d ",&a);
m=Not(a);
printf("%d\n",m);
break;
case 4:printf("Enter value of a&b");
scanf("%d %d",&a,&b);
n=Xor(a,b);
printf("%d\n",n);
break;
case 5:printf("Enter value of a&b");
scanf("%d %d",&a,&b);
p=Nand(a,b);
printf("%d\n",p);
break;
case 6:printf("Enter value of a&b");
scanf("%d %d",&a,&b);
r=Nor(a,b);
printf("%d\n",r);
break;
case 7:printf("exit");
break;
}
}
while(ch!=7);
}
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)
{
FILE *f;
f=fopen("agh.txt","w");
fputc('l',f);
fclose(f);
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);
fclose(f);
}
int Not(int a)
{
int output;
if(a==0 )
output=1;
if(a==1 )
output=0;
return (output);
}
int Xor(int a,int b)
{
int output;
if(a==0&&b==0)
output=0;
if(a==1&&b==1)
output=0;
if(a==1&&b==0)
output=1;
if(a==0&&b==1)
output=1;
return(output);
}
int Nand(int a,int b)
{
int output;
if(a==0&&b==1)
output=1;
if(a==0&&b==0)
output=1;
if(a==1&&b==1)
output=0;
if(a==1&&b==0)
output=1;
return(output);
}
int Nor(int a,int b)
{
int output;
if(a==0&&b==1)
output=0;
if(a==1&&b==1)
output=0;
if(a==1&&b==0)
output=0;
if(a==0&&b==0)
output=1;
return (output);
}