Computer Science, asked by dibyaparida1212, 7 months ago

Problem statement
You are required to implement the following fuction
int OperationChoices (int c, int a, int b)
The function accepts 3 positive integers a,b,c as its arguments. implement the function to return :
(a + b), if c = 1
(a - b), if c = 2
(a x b), if c = 3
(a / b), if c = 4
Assumption: All operations will result in integer output.
Example:
Input:
c: 1
a:12
b:16
Output:
Since c = 1, (12 + 16) is performed which is equal to 28,hence 28 is returned.
Sample Input
c:2
a:16
b:20
sample output
-4​

Answers

Answered by amuamu538
1

Answer:

#include<stdio.h>

int operationChoices(int c, int a , int b)

{

if(c==1)

{

return a + b;

}

else if(c==2)

{

return a - b;

}

else if(c==3)

{

return a * b;

}

else if(c==4)

{

return a / b;

}

}

int main()

{

int x, y, z;

int result;

scanf("%d",&x);

scanf("%d",&y);

scanf("%d",&z);

result = operationChoices(x, y, z);

printf("%d",result);

}

Answered by tanishathorat50
0

Answer:

python

def operationChoices(c,a,b):

if c == 1 :

return(a+b)

elif c == 2:

return(a-b)

elif c == 3:

return(a*b)

else:

return(a//b)

c,a,b = map(int,input().split())

print(operationChoices(c, a, b))

Output:

2 16 12 20

-4

Similar questions