Answer:
Following are the code to the given question:
#include <iostream>//header file
using namespace std;
int NumberOfPennies(int ND, int NP=0)//defining a method that accepts two parameters
{
return (ND*100 +NP);//use return keyword that fist multiply by 100 then add the value
}
int main() //main method
{
cout << NumberOfPennies(5,6) << endl; // Should print 506
cout << NumberOfPennies(4) << endl; // Should print 400
return 0;
}
Output:
506
400
Explanation:
In the method "NumberOfPennies" it accepts two parameters that are "ND and NP" that uses the return keyword that multiply 100 in ND variable and add in NP variable and return its values.
In the main method it it uses the cout method that call the by accepts value in parameter and print its value.
Answer:
The expressions in each part of an AND or OR expression use <u>Short Circuit</u> evaluation; that is, they are evaluated only as much as necessary to determine whether the entire expression is true or false.
Explanation:
Logic operations follow different type of evaluation methods that can be short circuit or open circuit evaluation. In short circuit evaluation if first operand of the expression is true or false in OR or AND operation respectively, the result will found as true or false without checking the second operand of the expression. This is called Short Circuit Evaluation.
In OR operation, If first operand is true it means that the result of the expression is true without knowing that the other operand is true or false. In AND operation, If the first operand is False, the result will found as False without knowing that whether the 2nd operand is true or false.
This Mechanism is called Short Circuit Evaluation.