Answer:
Following are the code to this question:
#include<stdio.h>//defining header file
int AND(int x,int y) //defining a method AND that hold two variable in its parameter
{
if(x==1 && y==1)//defining if block to check x and y value is equal to 1
{
return 1;//return value 1
}
else //defining else block
{
return 0;//return value 0
}
}
int OR(int x,int y)//defining method OR that hold two variable in its parameter
{
if(x==0&&y==0)//defining if block to check x and y value is equal to 1
{
return 0;//return value 0
}
else //defining else block
{
return 1;//return value 1
}
}
int main()//defining main method
{
int a,b,c;//defining integer variable
int k=1;//defining integer variable k that holds a value 1
while(k<=8)//defining while loop for 8 time input
{
printf("Please insert 3 numbers in (0 0r 1):\n ");//print message
scanf("%d%d%d", &a, &b, &c);//input value
k++;//increment the value of k by 1
printf("value: %d\n",AND(OR(a,b),c));
}
return 0;
}
Output:
please find the attachment.
Explanation:
In the above-given C language code two methods "AND and OR" is declared, holds two integer variable "x and y" in its parameters, inside the method a conditional it used that can be defined as follows:
- In the AND method, inside a conditional statement, if block check x and y both value is same that is 1 it will return 1 or it will goto else block in this it will return value 0.
- In the OR method, inside a conditional statement, if block check x and y both value is the same, that is 0 it will return 0 or it will goto else block in this it will return value 1.
- In the main method, four integers "a,b,c, and k" is declared in which variable "a, b, c" is used in the loop for 8 times input values from the user and print method is used to call the method and prints its return values.