#13. Let the function fun be defined as int fun (int k) *k + 4; return 3 (*k) - 1; Suppose fun is used in a program as follows: void main () int i- 10, j - 10, auml, aum2; suml - (1/2) + fun (61): sum2 - tun (6j) + (0/2): What are the values of suml and sum2? a. if the operands in the expressions are evaluated left to the right? b. if the operands in the expressions are evaluated right to the left?
Q: li en aretle Let the functions fun and main be defined as int fun(int *k) { *k += 2, return (*k) -…
A:
Q: A word is considered elfish if it contains the letters: e, l, and f in it, in any order. For…
A: use stl find in c++
Q: 3. Write the appropriate function definition for each of the following situations: a) Write a…
A: The question mainly focuses about use of the sum_even and sum_odd. Although the function has…
Q: Consider the following definition of function "Secret" and answer the question below void Secret…
A: Actually, array is a collection of elements.
Q: Consider the following definition of function "Secret" and answer the question below void Secret…
A: Given code: void secret(int &val1, int val2, int val3=9){ val2++; val3 = val3/2; val1 =…
Q: 3- Write a function pow (double base, int exp) to calculate integral powers of floating-point…
A: #include <iostream> #include <cmath> using namespace std; double pow1(double base, int…
Q: Question 2. a. Let the function fun be defined as int fun(int *k) { *k += 4; return 3 * (*k) - 1;…
A: The pointer variable is the variable which is to store the address of a variable or reference of a…
Q: 3. Consider a function header as: void fun(int w, int x, int y, int z) and the corresponding…
A: Functions in programming: Functions are designed to serve specific purposes. Parameters are sent by…
Q: function myCompose(f,g){// TODO: return (f o g);// that is, a function that returns f(g(x))…
A:
Q: Write a function def identical(a, b) that checks whether two tuples have the same elements in any…
A: Here is the approach : First we have to take the two tuple as the input parameters to the function…
Q: 3. Write the appropriate function definition for each of the following situations: b) Write a…
A: PROGRAM CODE: #include <iostream> // include header file for input output stream…
Q: 7.)Write a fruitful function sum_to(n) that returns the sum of all integer numbers up to and…
A: ANSWER 1: Fruitful Function:
Q: rps (Exercise 5.26 from the textbook) Write a function rps that returns the result of a game of…
A: The solution for the above given question is given below:
Q: Write a function double power(double x, int n) that will compute xn
A: This question comes from Programming Language which is a paper of Computer Science. Let's discuss it…
Q: (13.)Write a function slope(x1, y1, x2, y2) that returns the slope of the line through the points…
A: def slope(x1,y1,x2,y2): return (y2-y1)/(x2-x1)…
Q: Computer Science In C++ use the following STL algorithms: reverse, rotate, and shuffle. Write…
A: #include <algorithm>#include <iostream>#include <vector>using namespace std; int…
Q: 11. Given the following recursive definition f(1) = f(2) = 2 f(n) = 2∗f(n−1)+ f(n−2) write the C++…
A: code: #include<iostream> using namespace std; int c = 0; // function to calculate value of f()…
Q: Write a function definition for a function named firstLast to do the following: a. Accept an array A…
A: #include <iostream>using namespace std;//function takes array A and its size//returns a new…
Q: ( (7.)Write a fruitful function sum_to(n) that returns the sum of all integer numbers up to and…
A: This question comes from Python Programming Language which is a paper of Computer Science. Let's…
Q: Write a programme in C that will add 2 matrix and print the output matrix. Matrix will be 3 by 3…
A: 1 . C PROGRAM ==> #include <stdio.h>#include <stdlib.h> void addition(int…
Q: Problem Statement: Consider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is…
A: 1. Algorithm: Sort_TAM (TAMUK[]) start = 0, mid = 0, end = length(TAMUK) - 1 while mid <= end if…
Q: Write the appropriate function definition for each of the following situations: b) Write a function…
A: Function definition: void sum(int x[ ]){ int n=sizeof(x)/sizeof(x[0]);int sum_even=0;int sum_odd=0;…
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: Calling a recursive function. Write a statement that calls the recursive function…
A: Here we have a method named backwards_alphabet(). In this method, we check if the value passed as a…
Q: Define a function: Void Insert(char str1[], char str2[], int pos) to insert str2 to str1 from pos.…
A: Code: #include <stdio.h>#include <string.h>//Defining the required functionvoid…
Q: Q#1 Write a recursive function printRev ( int a[ ], int s, int e) that receives an integer array a…
A: PROGRAM CODE: #include <iostream> // include header file input output…
Q: 13. Let the function fun be defined as int fun (int*k) { *k +- 4; return 3 * (*k) - 1; Suppose fun…
A: According to the Question below the Solution:
Q: 9.02) A palindrome consists of a word or deblanked, un-punctuated phrase that is spelled exactly the…
A: Given:- IN C LANGUAGE it must ignore spaces and ohter symbols. when checking the input the code must…
Q: Question Description Consider the following C function: long func(long x, long y, long z) { long…
A: Solution: Given, long func(long x, long y, long z) { long ti = x + 3; long t2 - 2 + ti; long t3…
Q: Question 3: a) Write a C function count_digits() which takes an integer n as parameter and retums…
A: Recursion Recursion is the process of repeating items in a self-similar way. In programming…
Q: 4) Write a function power(double x, int y) to calculate powers of floating-point numbers. Arguments:…
A: PROGRAM CODE: #include <iostream> #include <cmath> using namespace std; double…
Q: In c++ please help me answer this question I will give you a good rating :) implement the three…
A: In this question we have to write a C++ program in which We will create three function for same…
Q: Study the following definition of function "Secret" and answer the question below. int Secret (int…
A: complete code: //include the header#include <iostream>using namespace std; //method…
Q: Write a user-defined function that compares two string with each other. If first one is equal to…
A: Function definition: A function is a subroutine that executes a set of instructions or a set of…
Q: 3. Observe the following formulae: fin) = 1 fin) = 3 + fln-1) fin) = 2+ fln-1) if n =0 if n is even…
A: a. If a function calls itself, it’s known as direct recursion. Function code: int f(int n){…
Q: Let the function fun be defined as int fun(int *k) { *k += 5; return 3 * (*k) - %; } Suppose fun is…
A: The answer is as follows:-
Q: 5. We know that the roots of a quadratic equation of the form are given by the following equations:…
A: Algorithm: Start Read a, b, and c values and store them in coefficients array of size 3 Declare an…
Q: 2) Write the definition of a recursive function named find that is passed a cstring and a char and…
A: Given: C++ Note: Implementation has to be recursive. Try not using loops while implementing, Meaning…
Q: 20. Write a user-defined function that plots a triangle and the circle that is inscribed inside,…
A: Actually, MATLAB is a programming platform designed specifically for engineers and scientists.
Q: 3.40 Implement function partition() that splits a list of soccer players into two groups. More…
A: This is your solution code
Q: Define a python function ‘australian_tennis(d)’ which reads a dictionary of the following form and…
A: Program code: #method to find the highest scorer def australian_tennis(test_list): highScore =…
Q: Write a C++ program that tests the function main and the functions discussed in parts 1 through 5.…
A: Pass the alpha array as constant pointer so that alpha doesn't gets updated and beta can be udpated
Q: Question no. 1
A: c++ code: #include <iostream>#include <iomanip> using namespace std; double…
Q: function [P, A] = rect(L, W) P= 2 (L+ W); A=L W; end Above function is defined to find perimeter and…
A: The function is rect and it is accepting two parameters length and width and returns perimeter and…
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: 2) Write the definition of a recursive function named find that is passed a c-string and a char and…
A: GIVEN:
Q: Consider the function definition: void GetNums(int howMany, float& alpha, float& beta)…
A: When GetNums function is calledWhen the GetNums function is called, then at first the run time…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- 12. Consider the recursive function int gcd( int a, int b) int gcd( int a, int b){ if (b > a) return gcd(b,a); if ( b == 0 ) return a; return gcd( b, a% b); } How many invocation (calls) of the gcd() function will be made by the call gcd(72, 30)?I need to complete this table, JAVA. Assuming an unsorted Map starting with no contents, describe the return values and contents of the map (initial values on the left) after the operation, when done in order. Also Assume entries are in (key,value) format. The first three function calls are completed. FUNCTION CONTENTS RETURN VALUE isEmpty() {} true put(5,X) {(5,X)} null put(7,F) {(5,X),(7,F) null put(2,C) put(8,D) put(2,E) get(7) put(7,Y) get(4) put(4,X) get(4) size() remove(5) isEmpty() size()Consider the following function definition.void mystery(int* x){// function body } Inside the definition of mystery, the C++ language provides a way to distinguish if x points to a lone int value or to an int allocated as part of a larger array.A. True B. False
- Problem 6: Induction and Recursion Consider a postal system for which the minimum postage required for any service (e.g. mailing a postcard) is 18 cents. [a] Prove by strong induction that any postage ≥ 18 can be formed using only 4-cent and 7-cent stamps. (Hint: consider bases cases for 18 thru 21.) [b] Write a Java/Python-like pseudocode for a function that determines the number of each denomination of stamp for a postage amount ≥ 18. (It need not be concerned with lesser cases as they are never used).1. Write a C program to count Non-Armstrong numbers from m and n (including m and n also) using the concept of passing pointers to function. Pass addresses of m, n and count integers from the main () function to the user defined function: calculate () [Function is not returning any value], and display the count in the main () function. 2. Write a program which should consists of a user defined function “Task ()” [Function returns no value]. Pass 1D array to the function, along with number of elements of array and element to search. Function should implement linear search, and if the element is not found in the array, then insert that element at the end of array .Display the final array after insertion [After function is called] in the main () function. [Note: Array should be passed using by reference approach]Please written by computer source Question 1: Suppose we wish to write a procedure that computes the inner product of two vectors u and v. An abstract version of the function has a CPE of 14–18 with x86- 64 for different types of integer and floating-point data. By doing the same sort of transformations we did to transform the abstract program combine1 into the more efficient combine4, we get the following code: Our measurements show that this function has CPEs of 1.50 for integer data and 3.00 for floating-point data. For data type double, the x86-64 assembly code for the inner loop is as follows: Assume that the functional units have the characteristics listed in Figure 5.12. **See last page for figures A. Diagram how this instruction sequence would be decoded into operations and show how the data dependencies between them would create a critical path of operations, in the style of textbook Figures 5.13 and 5.14. vmovsd vmovsd vmulsd vaddsd | | | |…
- Consider the following recursive function: def rec1(aList,first,last): if first==last: return aList[first] else: return aList[last]*rec1(aList,first,last-1) Show the output of the following call (show your work and all recursive calls): print(rec1([1,2,3,4,5,6,7],3,5))? describe the task of the rec1 function.Computer Science Consider the following Haskell functions:step x y = y + 1mystery iL = foldr step 0 iLWhat will the following expression evaluate to , show the execution and explainmystery ["ab","bc","cd","bc"]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;}
- Question Description Consider the following C function: long func(long x, long y, long z) { long ti = x + 3; long t2 - 2 + ti; long t3 - y + 5; long t4 = y = 33; long t5 - t3 + 14; long rval t2 + t5; return rval; } Show that the assembly code below is a correct translation of this program, by (a) giving an expres- sion for the value func() returns, and (b) filling in the table below the assembly code, showing the contents of each register in terms of x, y and z after each of the first six instructions is executed. The first row shows register contents before the first instruction. Remember that the sequence of assembly instructions may not correspond exactly to the C code, as the compiler may rearrange things to minimize the number of instructions and registersWrite a C++ program for the following In this task, your job is to create a function Swapper() that takes three arguments num1,num2, and difference. The first argument should be passed by pointer, second argumentshould be passed by reference, and third argument should be passed by value. YourSwapper function should first swap the values of num1 and num2 with each other, andthen compute the difference of most significant digits of both numbers. You have to storethe difference result in difference variable. In the end, you need to display the values ofall three variables inside your Swapper method as well as in your main function.Note: You are not allowed to create any other variable or pointer inside your Swappermethod.C/C++ & MIPS The function ?add(?,?) for two positive integers 0≤?, and 0≤?, is defined as the following:?add(?,0)=?; ?add(?,?)=?add(?,?−1)Write a recursive version of ?add() in C or C++, then use this program to develop a MIPSprogram that gets as input two integers 0<? ≤255, and 0<? ≤255, and returns theresult of ?add(?,?) in $v1.Your deliverable should be the C/C++ code and the MIPS assembly function-code