Sei sulla pagina 1di 2

#include<stdio.

h>
#include<stdlib.h>
int res;
int sum(int x,int y);
int sub(int x,int y);
int mul(int x,int y);
int divi(int x,int y);
int AND(int x,int y);
int OR(int x,int y);
int XOR(int x,int y);
int NOT(int x);
void main()
{
int choice,a,b;
printf("Select anyone of the following operations:\n");
printf("1.Addition\n 2.Subtraction\n 3.Multiplication\n 4.Division\n 5.AND\n
6.OR\n 7.XOR\n 8.NOT\n");
scanf("%d",&choice);

if(choice==1)
printf("Enter the two numbers:");
scanf("%d %d",&a,&b);
printf("Sum is %d\n",sum(a,b));
else if(choice==2)
printf("Enter the two numbers:");
scanf("%d %d",&a,&b);
printf("Difference is %d\n",sub(a,b));
else if(choice==3)
printf("Enter the two numbers:");
scanf("%d %d",&a,&b);
printf("Product is %d\n",mul(a,b));
else if(choice==4)
printf("Enter the two numbers:");
scanf("%d %d",&a,&b);
printf("Quotient is %d\n",divi(a,b));
else if(choice==5)
printf("Enter the two numbers:");
scanf("%d %d",&a,&b);
printf("Result is %d\n",AND(a,b));
else if(choice==6)
printf("Enter the two numbers:");
scanf("%d %d",&a,&b);
printf("Result is %d\n",OR(a,b));
else if(choice==7)
printf("Enter the two numbers:");
scanf("%d %d",&a,&b);
printf("Result is %d\n",XOR(a,b));
else if(choice==8)
printf("Enter the number:");
scanf("%d",&a,);
printf("Result is %d\n",NOT(a));
else
printf("That is not a valid choice. SORRY!!!\n");
}
int sum(int x,int y)
{
res=x+y;
return res;
}
int sub(int x,int y)
{
res=x-y;
return res;
}
int mul(int x,int y)
{
res=x*y;
return res;
}
int divi(int x,int y)
{
res=x/y;
return res;
}
int AND(int x,int y)
{
res=x&y;
return res;
}
int OR(int x,int y)
{
res=x|y;
return res;
}
int XOR(int x,int y)
{
res=x^y;
return res;
}
int NOT(int x)
{
res=~x;
return res;
}

Potrebbero piacerti anche