Write a user-defined function that accepts two numbers as parameters and displays their sum, difference, product and quotient.
Answers
Answered by
1
Answer:
Here's your answer.
Explanation:
def foo(x: int, y: int): # x and y are the parameters
print(f"Sum is {x+y}") # Sum
print(f"Difference is {x-y}") # Difference
print(f"Product is {x*y}") # Product
print(f"Quotient is {x/y}") # Quotient
foo(4, 2) # The function is called here. 4, 2 are the arguments
Answered by
0
Answer:
#include <stdio.h>
int sum(int ,int );
int diff(int,int);
int pro(int,int);
int main (){
int a, b,result;
printf("Enter First Integer : ");
scanf("%d",&a);
printf("Enter Last Integer : ") ;
scanf("%d",&b);
result = sum(a,b);
printf("The sum of %d and %d is %d . \n",a,b,result);
result = diff(a,b);
printf("The difference of %d and %d is %d . \n",a,b,result);
result = pro(a,b);
printf("The product of %d and %d is %d . \n",a,b,result);
return 0;
}
int sum( int a, int b){
return a+b; }
int diff( int a, int b){
return a-b;}
int pro( int a, int b){
return a*b;}
Explanatio
#include <stdio.h>
int sum(int ,int );
int diff(int,int);
int pro(int,int);
int main (){
int a, b,result;
printf("Enter First Integer : ");
scanf("%d",&a);
printf("Enter Last Integer : ") ;
scanf("%d",&b);
result = sum(a,b);
printf("The sum of %d and %d is %d . \n",a,b,result);
result = diff(a,b);
printf("The difference of %d and %d is %d . \n",a,b,result);
result = pro(a,b);
printf("The product of %d and %d is %d . \n",a,b,result);
return 0;
}
int sum( int a, int b){
return a+b; }
int diff( int a, int b){
return a-b;}
int pro( int a, int b){
return a*b;}
Explanatio
Similar questions