Can someone help answer this question on C Consider the foll
Can someone help answer this question on C++?
Consider the following functions:
What is the output of each of the following program segments?
Solution
Answers
a) 62
b)20160
c)20213837312
1
Solution.cpp
#include <iostream>//header file for input output function
using namespace std;//it tells the compiler to link std namespace
int find(int num1, int num2)
{//function definition
int first, second;//variable declaration
first = num1 * num2;
second = first - num1 + num2;
if (second > 50)
num1 = first / 10;
else
num2 = second / 20;
return num1 + num2;
}
int discover(int one, int two)
{//function definition
int secret = 1;
for (int i = one; i < two; i++)
secret = secret * i;
return secret;
}
int main()
{//main function
cout << find(15, 25) << endl;//function calling
cout << discover(3, 9) << endl;//function calling
cout<<find(10,10)<<\"\"<<discover(10,find(10,10))<<endl;//function calling
int x = 20,y = 10;
cout << discover(x, y) << endl;//function calling
return 0;
}
output
62
20160
20213837312
1

