1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
gogolik [260]
3 years ago
4

Consider the following functions: (4) int hidden(int num1, int num2) { if (num1 > 20) num1 = num2 / 10; else if (num2 > 20

) num2 = num1 / 20; else return num1 - num2; return num1 * num2; } int compute(int one, int two) { int secret = one; for (int i = one + 1; i <= two % 2; i++) secret = secret + i * i; return secret; } What is the output of each of the following program segments? a. cout << hidden(15, 10) << endl; b. cout << compute(3, 9) << endl; c. cout << hidden(30, 20) << " " << compute(10, hidden(30, 20)) << endl; d. x = 2; y = 8; cout << compute(y, x) << endl;
Computers and Technology
1 answer:
Olin [163]3 years ago
3 0

Answer:

a.  cout<<hidden(15,10)<<endl;

output = 5

b. cout << compute(3, 9) << endl;

output=3

c. cout << hidden(30, 20) << " " << compute(10, hidden(30, 20)) << endl;

output = 10

d. x = 2; y = 8; cout << compute(y, x) << endl;

output= 8

Explanation:

solution a:

num1= 15;

num2= 10;

according to condition 1, num1 is not greater than 20. In condition 2, num2 is also not greater than 20.

so,

the solution is

return num1 - num2 = 15 - 10 = 5

<em>So the output for the above function is 5.</em>

<em></em>

solution b:

as in function there are two  integer type variables named as one and two. values of variables in given part are:

one = 3

two = 9

secret = one = 3

for (int i= one + 1 = 3+1 = 4; i<=9%2=1; i++ )

9%2 mean find the remainder for 9 dividing by 2 that is 1.

//  there 4 is not less than equal to  1 so loop condition will be false and loop will terminate. statement in loop will not be executed.

So the answer will be return from function compute is

return secret ;

secret = 3;

<em>so answer return from the function is 3.</em>

<em></em>

solution c:

As variables in first function are num1 and num2. the values given in part c are:

num1 = 30;

num2= 20;

According to first condition num1=30>20, So,

num1= num2/10

so the solution is

num1 = 20/10 = 2

now

num1=2

now the value return from function Hidden is,

return num1*num2 = 2* 20 = 40

Now use the value return from function hidden in function compute as

compute(10, hidden(30, 20))

as the value return from hidden(30, 20) = 40

so, compute function becomes

compute(10, 40)

Now variable in compute function are named as one and two, so the values are

one= 10;

two = 40;

as

secret = one

so

secret = 10;

for (int i= one + 1 = 10+1 = 11; i<=40%2=0; i++ )

40%2 mean find the remainder for 40 dividing by 2 that is 0.

//  there 11 is not less than equal to  0 so loop condition will be false and loop will terminate. statement in loop will not be executed.

So the answer will be return from function compute is

return secret ;

secret = 10;

<em>so answer return from the function is 10.</em>

solution d:

Now variable in compute function are named as one and two, so the values are

one = y = 8

two = x = 2

There

Secret = one = 8;

So

for (int i= one + 1 = 8+1 = 9; i<=2%2=0; i++ )

2%2 mean find the remainder for 2 dividing by 2 that is 0.

//  there 9 is not less than equal to  0 so loop condition will be false and loop will terminate. statement in loop will not be executed.

So the answer will be return from function compute is

return secret ;

secret = 8;

<em>so answer return from the function is 8.</em>

You might be interested in
Just a smol question how do i change my username on this?
strojnjashka [21]

Answer:

If you want to change your username, you have to contact them and tell them that you want to change. That is the only way.

Explanation:

7 0
3 years ago
Read 2 more answers
A period in which unemployment is low, business produces many goods and services, and wages are good is called ______.
ddd [48]

Answer:

A

Explanation:

4 0
3 years ago
I need an If else statement that sorts three numbers from a file from least to greatest
Vera_Pavlovna [14]
Void sort3(int& a, int& b, int& c)
{
if (a > b)
{
std::swap(a, b);
}
if (b > c)
{
std::swap(b, c);
}
if (a > b)
{
std::swap(a, b);
}
}
5 0
2 years ago
When a primary key combines two or more fields, it is called a ____ key?
Tanya [424]
<span>When a primary key combines two or more fields, it is called a ____ key
the answer is Constructed key</span>
6 0
3 years ago
PLEASE PLEASE PLEASE PLEASE help me Im completly lost will give brainliest and 50 points
pav-90 [236]

It can be either a or b.. I suggest go with b

3 0
3 years ago
Read 2 more answers
Other questions:
  • I’m which part of a profession email should you try to be brief, but highly descriptive
    7·1 answer
  • What is a hobbyist for engineering
    7·1 answer
  • simpley convert the code below to assembly languageYour proof-of-study task is to hand-compile the code below into an assembly l
    11·1 answer
  • The term _______ is used to refer to programs that attackers install after gaining unauthorized access to a system, ensuring tha
    15·1 answer
  • Why do i get message notifications but when i click on it it says i have no new messages?
    7·1 answer
  • What is one thing the ADDIE model does NOT account for?
    14·1 answer
  • What is the difference between Input, Output, and Storage Devices?
    12·2 answers
  • Have a good christmas. this might not be homework, but i just want everyone to have a good week
    6·2 answers
  • Radio spectrum is the part of the complete range of electromagnetic waves that is used for radio communication from
    14·1 answer
  • General Electric saves $1.6 billion per year by using its private corporate network that links its 340,000 employees. Another na
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!