int hidden(int num1, int num2) { if (num2 > 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 <= twp % 2; i++) secret = secret + i * i; return secret; } What is the output of each othe follorinw 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;
Q: This challenge is based on the classic videogame "Snake". Assume the game screen is an n * n square,…
A: In this problem, we need to design the code in the Python programming language. Input - Integer…
Q: Implement the following: 1) Define a function subMessage() which takes two parameters, a and b. a is…
A: Program import random def subMessage(text1,n): substr=text1[0:n] print(substr) n =…
Q: Given a struct Date, please overload the operator + to calculate the addition of two dates. struct…
A: #include <iostream>using namespace std; struct Date{ int year; int month; int day;…
Q: Complete the function solveMeFirst to compute the sum of two integers. In javascript
A: Algorithm: Start Read 2 numbers a and b Implement a method named solveMeFirst() that takes 2…
Q: int GetHashIndex(const T& elem) { return 0; How would this affect the Big-oh for the following…
A: NOTE: Either your GetHashIndex() function is incomplete or this is a very easy question. Explanation…
Q: Here is a function prototype: int getTotal(int, double, string); Which of these prototypes would…
A: Method Overloading is a feature that allows a class to have more than one method having the same…
Q: Implement the following functions without using the library: a. int power (int n, int m) [Returns:…
A: Here, Code instruction is given.
Q: This question involves the implementation of the MultipleGenerator class which generates a random…
A: I give the code in java along with code screenshot and output screenshot
Q: The following function prints the powers of 2 from 1 through n (inclusive). For example, if n is 4,…
A:
Q: void recurse(int num) { if (num == 0) cout << “ Zero” << endl; else { cout << " " <<…
A: NOTE: - The call being made to recurse(num +1) in else statement is missing the semi-colon. if…
Q: Create a function that takes the number x and the letter y ("m“ for the male, "f" for the female),…
A: In this problem we need to design a code to display the gernation as per the given information. In…
Q: IT provides best solutions for manual work that makes life easier .Suppose a university war manage…
A: The C program is given by #include<stdio.h> struct Student { char* Name; int RegId; char*…
Q: A java program where the system should use the following methods: .a) Lagrange interpolation for…
A: Interpolation is a method of finding new data points within the range of a discrete set of known…
Q: Implement the following function: 1) Name: GenerateRandom 2) Parameters: a (int), b (int),…
A: Algorithm: Create GenerateRandom(a,b,n) function. Generate n random numbers by,for i=0 to i=n-1…
Q: Design a class ProblemSolution to overload a function solution. Write a function int…
A: import java.util.*; public class ProblemSolution{ static int solution(int N, char CH) { //…
Q: Function power of type real - int - real that raises a real number to an integer power. For example…
A: Function power of type real * int - real......
Q: Write a program called p3.py that contains a function called reveal_recursive () that takes a word…
A: def word(x,n): for i in range(0,len(x)): if i<=n: print(x[i],end="")…
Q: g(x) = g(x - 1) * g (x - 3) if x is even and x > 3 = g(x - 2) if x is odd and x > 3 = x…
A: The base case is when X is less than or equal to 3 and in all other cases we call the function…
Q: solve the problem in java: Consider the are n=2 subjects and needed =[4,5] answered questions, to…
A: imports used import java.util.*;
Q: You are tasked with writing a small part of a museum's ticketing system. The museum calculates…
A: logic: admissionRate=20 total=0 for i in arr: if i<15:…
Q: Define a function ComputeGasVolume that returns the volume of a gas given parameters pressure,…
A: Inside main function, read pressure, temperature and number of moles as a user input. Call…
Q: Exercise 6: Area of a Circular Sector Write a function area_of_circular_sector() which • takes 2…
A: In this program question using python We have to calculate area of circular sector using two…
Q: Write a function in Java. Also, write a JUnit test output the following things should be output…
A: Solution:-- 1)The given question has required for the solution which is to be provided in the form…
Q: Define a function CalcPyramidVolume with double data type parameters baseLength, baseWidth, and…
A: here a function is added called CalcPyramidVolume() for calculating the volume of the pyramid.…
Q: #Quiz #Make a class that has 2 pieces of data (x, y) #In the init, take x as a parameter and ask the…
A: Purpose of the program: This program would create a class including the following functionalities…
Q: Explain the functionality of below recursive functions. static void fun1(int n) { int i = 0; if…
A: Recursion : => Recursion happens when something is described in terms of itself or of its type.…
Q: Consider the following function: public void bSearch(int[] A, int value, int start, int end) { if…
A: Solution: Given,
Q: This is a programming assignment. You can use any programming language. Program a Genetic Algorithm…
A: ANSWER:--
Q: Please right 2 different simple program;
A: The first question will be answered only. Here we divide the input number into digits existing at…
Q: Consider the following recursive function: void recurse(int num) { if (num == 0) cout <<…
A: Conditions for the recursive function: Every recursive function must have a valid terminating base…
Q: Given a struct Date,please overload the operator + to calculate the addition of two dates. struct…
A: #include <iostream>using namespace std; struct Date{ int year; int month; int day;…
Q: Write a program called p3.py that contains a function called reveal_recursive() that takes a word…
A: Python code:- def reveal_recursive(str,strLen): for i in range(strLen): for j in range(i+1):…
Q: There are constants in B4 and B3 that will be utilized for every computation in the following…
A: Excel is the spreadsheet application , that allows user to create, view , edit and share the…
Q: Write a program to help a university system to store records for its employee. You have to perform…
A: Code: #include <string>#include <iostream>#ifndef EMPLOYEE_H#define EMPLOYEE_H using…
Q: the sum of each pair's values is exactly equal to the target sales. Input The input to the…
A: Java code :- import java.util.*;public class Solution { public int pairs(int n,int[] arr,int…
Q: Python def fancy_quadratic(a: float, b: float, c: float, x: float) -> float: """ fancy_quadratic(a,…
A: 1. Already given in the question in fancy quadratic return the value of ax²+bx+c so return the…
Q: 1. Write a Java program to print 'Hello' on screen and then print your name on a separate line.…
A: Note: Multiple questions are given in one part. According to the rule, you will get the answer for…
Q: Write a recursive function called poweroftwo that returns the k" power of 2. As an example, the call…
A: Given:
Q: Consider the following recursive function: void recurse(int num) { if (num == 0)…
A: EXPLANATION: “Yes”, the given call recurse (-2) us a valid call. This calls the recurse function…
Q: Consider this very simple function: def cube(x): answer = x*X*X return answer a) Here is a fragment…
A: Lets analyse the given code: def cube(x): #takes variable x as input argument answer =…
Q: code in python (A) please Solve the so-called "Birthday Problem". Write a program that takes an…
A: Summary: -Hence, we got the output
Q: 1. Define a function extract_grade(x): • x: A string containing a student number and grade in the…
A: We need to Define a function extract_grade(x) , class_average(final_marks) ,std_dev(final_marks):
Q: The greatest integer function is defined by int(x) = the greatest integer that is…
A: GREATEST INTEGER FUNCTION: The Greatest Integer Function [X] is also called the floor of X. This is…
Q: def mystery_function (nl, n2): if n2 - nl > 0: return n2 -n1 elif n2 - nl < 0: return n1 - n2 else:…
A: - We have to talk about the functionality of the function provided.
Q: Create a function that takes a number that represents a person's programming language score, and…
A: In this problem, we need to design a code in javascript Input - integer Output - array Logic -…
Q: This challenge is based on the classic videogame "Snake". Assume the game screen is an n *n square,…
A: Algorithm - Take input from the user. Now use the below logic - res = 1 count = 0 while…
Q: .The following is the C code that you need to implement for this lab: uint8_ t f(uint8_tn)…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: Write a function using Java Function Name: winInRow Parameters: board: 2D integer array, row:…
A: - We need to complete the modified tic tac toe. - We have to use java language here.
Q: Ô https://learn.zybooks.com/zybook/SNHUIT140V3/chapter/5/section/7 My library > IT 140: Introduction…
A: Input : User Ounces Output : Compute the Popcorn time and print it.
Consider the following functions:
int hidden(int num1, int num2)
{
if (num2 > 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 <= twp % 2; i++)
secret = secret + i * i;
return secret;
}
What is the output of each othe follorinw 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;
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- The greatest integer function is defined by int(x) = the greatest integer that is ....................For example, int(2.5) = ................ int(-2.5) = ............... and int(0.5) = ...................You are tasked with writing a small part of a museum's ticketing system. The museum calculates ticket prices using the following rules: $20.00 per admission. Children under 15 get a 50% discount. Seniors (60 years and older) get a 25% discount. Write a Python function that takes a list of customers' ages and returns the total cost for the group. Your function must match the docstring below. You do not need to include the docstring in your solution. '''Function -- get_ticket_costCalculates the cost of museum admission for a group.Parameter:group_ages -- A list of integers representing customer ages.Returns:The total cost for the group, a float. The return value is not rounded.''' Example get_ticket_cost([10, 39, 40]) returns 50.0Please answer it in Python 1) Write a function last_consonant that takes as an argument a word and returns two return values: the index of its last consonant and the last consonant (as for lists, we will consider that the index of the first letter is zero). We will not deal with the problematic case where the word does not contain a consonant. Example: last_consonant('arrivee') returns 4, 'v' 2) Write a function double_consonant that takes as an argument a word and has two return values: a Boolean worth True if the word contains a double consonant (twice the same consonant in a row), and in this case the second return value is the consonant that is doubled; if there is no doubled consonant, the function must return False and None. If the word contains several double consonants (for example, 'successor'), true will be returned and the first double consonant appearing in the word. Examples: double_consonant('arrive') is True, 'r'. double_consonant ('candy') is false, none…
- In java: Develop a function that accepts an array of integers and returns their average. Develop a function that accepts an array of integers and a threshold value from the user. The function returns how many values in the array are strictly greater than the cutoff. Using the functions written for #1, #3, and #4, find the number of values above average in two randomly generated arrays. Develop two functions:a. a function that returns the index of the maximum value in an array of integers passed by a caller, the caller prints the returned index and the value at that indexb. a function that returns the index of the alphabetically first value in an array of strings, the caller prints the returned index and the value at that inde Develop two functions:a. a function that swaps the alphabetically first value in an array of Strings with the first value in the array. Call this function twice on two different arrays of Strings; in the caller, use the function written for #2b to display…Design a class ProblemSolution to overload a function solution. Write a function int solution(int N, char CH) that accepts integer N and character CH. The function should return square of a number (N) if a character (CH) is "s" otherwise return cube of a number. int solution(int N, int M, char CH) that accepts two integers (N and M) and one character CH. The function should return the product of two integers if a character (CH) is ‘p’ otherwise return their sum. boolean solution(String S1, String S2) that accepts two strings S1 and S2. The function should return true if S1 and S2 are equal otherwise false. Input 1 4 s where, First line represents a choice for calling one of the defined methods. (1 for solution(int N, char CH), 2 for solution(int N, int M, char CH) and 3 for solution(String S1, String S2)). Second line represents number input. Third line represents choice CH. Output 16 Here, the first line contains 1 and hence solution(int N, char…Python Functions for Statistical Applications 1A. Implementation with the standard def keyword Suppose you have done a statistical comparison using the Z-scores approach. Write a function for calculating the lower bound of the 95% CI. A starter code for this function is already provided to you below. def compute_lower_bound(n, mu, stdev, z=1.96):"""Computes lower bound of a confidence intervalParameters:n: Type int. number of data pointsmu: Type float. sample meanstdev: Type float. sample standard deviationz: Type float. critical value. Default to 95%CI that corresponds to value of 1.96"""# YOUR CODE HERE# Hint: A correct implementation can be as short as just 1 line long! 1B. Using the function of Part 1A Run your function on the following scenario: There are 500 data points. The sample mean is 2525 The sample standard deviation is 7.57.5 The critical value at 95% confidence, ?0.95�0.95, is a constant: 1.96 # YOUR CODE HERE 1C. Application of Part 1A Now, you are asked to do the…
- Consider the following recursive function. What does it calculate in terms of x, y, and z? 01: Private Function CalcRecurse(ByVal x As Integer, ByVal y As Integer, ByVal z As Integer) As Integer 02: If x <= 1 Then 'Assume that CalcRecurse always starts with x > 1 03: Return y 04: Else 05: Return z + CalcRecurse(x - 1, y, z) 06: End If 07: End FunctionThe following recursive function takes three positive integer arguments: def compute(n,x,y) : if n==0 : return x return compute(n-1,x+y,y) What is the value returned by the compute function? n*x+y x+y x+n*y x What if: will the returned value be for the compute function defined in the question above if the argument n is negative? x x-n*y x+n*y The function will never return a value.Implement a program that contains the following two functions: 1. A function that accepts a list of numbers as an argument, the function should recursively calculate the sum of all the numbers in the list and returns that value2. A function that uses recursion to raise a number to a power. The function should accept two arguments: the number to be raised, and the exponent. Assume the exponent is a positive integer
- Implement in C Programming 6.10.2: Pass by pointer. Write a function call to ConvertMoney() to store the number of quarters, nickels, and pennies within the integer variables numQuarters, numNickels, and numPennies, respectively. Ex: If the input is 133, then the output is: Quarters: 5 Nickels: 1 Pennies: 3 #include <stdio.h> void ConvertMoney(int totalPennies, int* numQuarters, int* numNickels, int* numPennies) { *numQuarters = totalPennies / 25; totalPennies = totalPennies % 25; *numNickels = totalPennies / 5; totalPennies = totalPennies % 5; *numPennies = totalPennies;} int main(void) { int totalPennies; int numQuarters; int numNickels; int numPennies; scanf("%d", &totalPennies); /* Your code goes here */ printf("Quarters: %d\n", numQuarters); printf("Nickels: %d\n", numNickels); printf("Pennies: %d\n", numPennies); return 0;}1.The following is the C code that you need to implement for this lab: uint8_ t f(uint8_tn) return(n<2)?(n):(f(n-1)+f(n-2)); The main function can be assumed as follows: int main() uint8_ t x; x=f(???); return 0; Obviously, " ? ? ? " is representing a value used to test the algorithm! Is "f"recursive? a.No answer text provided. b.Yes c.no d.depends on whether it is in for main 2.First, make the code in the previous question an actual C program so that it can be compiled and it runs. Play with it so that you feel comfortable with the logic of the code. Then implement the code in TTPASM. Note that you need to preserve the actual C code structure, this means you cannot it into a non-recursive subroutine. Furthermoreall conventions discussed in class regarding subroutines must be followed. The idea is that I should be able to substitute f with my own code, and main should work. Or, I can substitute main with my own, and f should work. Attach the source code of your assembly…Programming Language: C Write the following three functions: a) The function gets an array A of length n of ints, and a boolean predicate pred. It returns the smallest index i such that pred(A[i])==true. If no such element is not found, the function returns -1. int find(int* A, int n, bool (*pred)(int)); b) The function gets an array A of length n of ints, and a function f. It applies f to each element of A. void map(int* A, int n, int (*f)(int)); c) The function gets an array A of length n of ints, and a function f. The function f gets 2 ints and works as follows: 1. Start with accumulator = A[0] 2. For i=1...length-1 compute accumulator=f(accumulator, A[i]) 3. Return accumulator For example, if f computes the sum of the two inputs, then reduce() will compute the sum of the entire array. int reduce(int* A, int n, int (*f)(int,int)); Test for the functions: // used for test Q3-find bool is_even(int x) { return x%2 == 0; } bool is_positive(int x) { return x>0; } void…