1. Create a function with the name “ten” that takes two arguments. Both arguments are integers, a and b. Return true if one of them is 10 or if their sum is 10. Variables should be taken by user in the main function.
/******************************************************************************
*C++ function with the name “ten” that takes two arguments.
*Both arguments are integers, a and b.
*Return true if one of them is 10 or if their sum is 10.
*******************************************************************************/
#include <iostream>
using namespace std;
//Function declaration
bool ten(int a, int b);
//Driver code
int main()
{
int a, b;
cout<<"Enter the first number: ";
cin>>a;
cout<<"Enter the second number: ";
cin>>b;
cout<<ten(a, b);
return 0;
}
//Function definition
bool ten(int a, int b)
{
//If either a or b is 10 or a+b is equal to 10
if(a == 10 || b == 10 || (a + b) == 10)
{
//return true
return true;
}
}
Comments
Leave a comment