Consider the following function: int secret(int m, int n){int temp = n;for (int i = 1; i < abs(m); i++)temp = temp + n;if (m < 0)temp = -temp;return temp;} a. What is the output of the following C++ statements? i. cout << secret(18, 4) << endl; ii. cout << secret(-10, 20) << endl;b. What does the function secret do?
Q: Write a program in C++ using libraries. Write a function that allows case-insensitive comparison of…
A: String: String is nothing but a sequence of characters.
Q: Remember that a number n is a multiple of another number, k, only if n is divisible by k–that is,…
A: Task :- Write a python program to identify if all the numbers in given list are multiple of some…
Q: write a program in C++, to read a string (M[10]) ,send it to a function (My F()) that finds: 1."NL"…
A: #include <iostream>#include <cctype>#include <cstring>using namespace std; void…
Q: Write a Python function power(f,n) that takes a function f and an integer n, and returns a function…
A: Python pow () function returns the power of the given numbers. This function computes x**y. This…
Q: For the following programming problems, you need to time a section of code in C++. For example, the…
A: given:
Q: Write a C language function named count that takes a void pointer and int parameter, representing a…
A: Program code: #include <stdio.h> #include <stdint.h> int count(void *buf, int…
Q: write a function that gets 3 pointers int* a, int* b, int* c, and rotates the values in their…
A: note that a gets the value of b and we are working on pointers here so a will loose its originality.…
Q: Consider the following function interface: void short_and_long(char **p, int n, int *short, int…
A: #include <stdio.h> // Assuming all strings terminate with '\0' void short_and_long(char** p,…
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: Your task is to write a function toLeetSpeak that converts a regular english sentence to Leetspeak.…
A: Iterate over the input sentence Use another string and keep on updating respective value from…
Q: Write in Java: Write a program that takes in a positive integer as input, and outputs a string of…
A: Programming Approach: Importing necessary package Declaring main class Defining the main method…
Q: // Description: Write a program that outputs a root of a given function f(x) by using a bi-section…
A: According to the information given:- We have to find the outputs a root of a given function f(x) by…
Q: Write program in python with a function occupy(n), which shows how birds are going to occupy n…
A: Given that, Writing a program in python with a function occupy(n), which shows how birds are going…
Q: Write a python function that takes a positive integer n as an argument. This function will return…
A: Please find the code below:
Q: Consider the following function: int secret(int m, int n) { int temp = n; for (int i = 1; i <…
A: Explanation: i) cout << secret(5, 4) << endl; The operations involved in the above…
Q: Given a string S of characters, write a C function countAndPrint that prints on the screen all the…
A: //C program #include<stdio.h> #include<string.h> //count and print substrings void…
Q: def myfun ( x: Int, if x 0)': string) : String - { y + x, toString } else { myfun( x - 2 , "world" )…
A: Here we write answer of all the 6 Question marks:…
Q: 17. Consider the following "C" code segment. At least how many test cases are needed for achieving…
A: Each branch of every possible decision point has to be executed at least once. So let's find the…
Q: Write a function in C++, int solution(int N, char CH) that accepts integer N and character CH. The…
A: Write a function in C++, that accepts integer N and character CH. The function should return the…
Q: Write a C++ program that would implement the function called filterString which accepts a string s…
A: Here I have defined the function named filterString(). In this method, I have looped over the string…
Q: Here's the task in c program that I need. Instructions: Ask the user for a string input From…
A: Algorithm: Start Read a string s Iterate through the string from i=0 to s[i]!='\0' If…
Q: Write a program to reverse the words of a string. Implement a function reverse () that reverses the…
A: Following is the C program that implements a function reverse which reverses the selected part of…
Q: 1-Using C++ predefined functions, write each of the following as C++ expression. + 2b…
A: As per our guidelines, we are not supposed to answer more than three subparts of a question and…
Q: in c++ write a code where: Let a and b be integers such that either a or b is nonzero. The greatest…
A: GIVEN: Create a C++ program to find the gcd of the integers, such that a and b be integers such that…
Q: Write a c++ code and test the “digit” function: Function Prototype: int digit(int n,int k) This…
A: In step 2, you will the C++ code.In step 3, you can see the sample output.
Q: Write a c++ code and test the “digit” function: Function Prototype: int digit(int n,int k) This…
A: int digit(int n,int k){ string str; str = to_string(n); if(k>=str.length()) return…
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: Problem 1 What is this? what does the following program do? "C language" #include #define…
A: Given Program: #include <stdio.h> #define SIZE 10 int whatIsThis(const int b[], size_t p);…
Q: What will the following C function print? Be exact! void foo (int a) { int * p1 = &a; int **p2 spl;…
A: int* is the pointer variable which stores the address of an integer variable and int** is the…
Q: Create a function that takes an integer n and returns multiplication table of 1 to n numbers up to n…
A: function multTable(n) { var arr = [] for (let i = 1; i <= n; i++) { var hold = [] for (let j = 1;…
Q: write a C/C++ program that defines a function Lucas() that calculates the n th number in a Lucas…
A: This can be done using recursion and using loops
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: e in C. Can there be some comments included to show some guidance as to what is happening in the…
A: the solution is an given below :
Q: Your program should be modular and consists of the following functions: a) read () : - Ask the user…
A: def write_to_file(table):file = open("output.txt", "w")headerLine1 =…
Q: For the following programming problems, you need to time a section of code in C++. For example, the…
A: The answer is given below:-
Q: Implement a function alterCase in Python that converts a word to "alterCase". Given a word, using…
A: Input Data : The string from the user Output Data : Altering the string as per the given…
Q: Write the C equivalent “train” function #void train(int*A, int*B, int*C, int k) train: add…
A: I have decoded the MIPS code and written all 11 instructions with a meaning along with the MIPS…
Q: Program in python. There is function F. Give an integer n (n ≥ 2), consider the prime factorization…
A: Answer: In the above problem value od 125 largest prime factor is 5. In the below code you can see .…
Q: With function: void swapNum(int n1, int n2) { int temp = n%; %3D n1 = n2; n2 = temp; %3D And with…
A: Swapping two number in C programming language means exchanging the values of two variables.
Q: 10. What is the result of the following code in C++ ? (assume all #include and the unseen code is…
A: p points to array x then exchange values using pointer in the for loop to after exchanging value…
Q: Write a short Python function, minmax(data), that takes a sequence of one or more numbers, and…
A: First of all assign large and small with the first value of data. Compare the small and large with…
Q: Program in python There is function F. Give an integer n (n ≥ 2), consider the prime factorization…
A: If p is top, then φ § = p – 1 and φ (pa) = p a * (1 – 1/p) for any a.If m and n are coprime, then φ…
Q: In C++, write a program that accepts an amount in Peso from the user and converts it to its word…
A: C++ is a general-purpose programming language created by Bjarne Stroustrup as an extension of the C…
Q: Write a program in C++that contains overloaded functions with name OvOperation(). When the main…
A: The Answer is
Q: A common programming problem is maintaining a list in numerical or alphabetical order. For example,…
A: Actually, program is a executable software that runs on a computer.
Q: Write a C++ function, lastLargestIndex, that takes as parameters an int array and its size and…
A: Given: Write a C++ function, lastLargestIndex, that takes as parameters an int array and its size…
Q: 3. Write a function TrapezoidalRule.m which takes three input arguments f, a and b and returns one…
A: function [I] = TrapezoidalRule(f, a, b)% This function calculates the integral of a function, f,…
Q: For this exercise, write a function that inserts a three-digit part number in a list of part…
A: package Java.C.c; import java.util.*; import java.lang.*; import java.io.*; class value {…
Q: 2. Write and test a user-defined function with prototype int f1 (int N); that accepts an integer N…
A: Here since programming language not mentioned, using C++
Q: /* Write a function `coinProblem` that takes * 3 arguments: N, M and K; and solves following *…
A: PROGRAM EXPLANATION: Include the header file. Define a function coin problem(), this function will…
Consider the following function:
int secret(int m, int n)
{
int temp = n;
for (int i = 1; i < abs(m); i++)
temp = temp + n;
if (m < 0)
temp = -temp;
return temp;
}
a. What is the output of the following C++ statements?
i. cout << secret(18, 4) << endl;
ii. cout << secret(-10, 20) << endl;
b. What does the function secret do?
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Consider the following C++ function. int mystery(int num1, int num2){if (num1 > 0){for (int i = 1; i <= num1; i++)num2 = num2 * i;return num2;}else if (num2 > 0){for (int i = 0; i <= num2; i++)num1 = num1 + i;return num1;}return 0;}What is the output of the following statements?a. cout << mystery(4, -5) << endl;b. cout << mystery(-8, 9) << endl;c. cout << mystery(2, 3) << endl;d. cout << mystery(-2, -4) << endl;Write the C equivalent “train” function #void train(int*A, int*B, int*C, int k) train: add $t4, $0, $0bus: add $t5, $t4, $a1 lw $t6, 0($t5) add $t5, $t4, $a2 lw $t7, 0($t5) add $t6, $t6, $t7 add $t5, $t4, $a0 sw $t6, 0($t5) addi $t4, $t4, 4 slt $t5, $t4, a3 bne $t5, $0, bus jr raConsider the following function: int secret(int m, int n) { int temp = n; for (int i = 1; i < abs(m); i++) temp = temp + n; if (m < 0) temp = -temp; return temp; } What is the output of the following C++ statements? i.cout << secret(5, 4) << endl; ii.cout << secret(-3, 20) << endl;
- 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…In JAVA A function foo takes three integers as input arguments, i.e., foo(int a, int b, int c). The three inputs represent the three sides of a triangle in centimeter. The function is expected to return the type of a triangle: “equilateral”, “isosceles”, or “scalene”. Assume the domains of the three variables are 1 ≤ a ≤ 100, 50 ≤ b ≤ 150 and 100 ≤ c ≤ 200, respectively. A test case is in a tuple format <a, b, c, expected_output> with test inputs and the expected output. S1 is a set of test cases for the “Boundary Value Analysis” approach. S1 = S2 is a set of test cases for the “Robustness testing” approach. S2 – S1 = S3 is a set of tests cases for the “Robust Worst-Case testing” approach. Are there any types of triangles that S3 cannot reveal? If yes, what are they? If no, why?(Program) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters, such as zerocount, onecount, twocount, and so forth, to 0. Then generate a large number of pseudorandom integers between 0 and 9. Each time 0 occurs, increment zerocount; when 1 occurs, increment onecount; and so on. Finally, display the number of 0s, 1s, 2s, and so on that occurred and the percentage of time they occurred.
- Consider the following C function or Java method (except for final printstatement the code is the same):void fun (int x) {int a, b, c, d;d = 1;for (a = 1 ; a <= x ; a ++) {b = a;c = 1;while (b > 0) {c &= b % 2;b /= 2;}d += c;}printf ("%d\n", d);}void fun (int x) {int a, b, c, d;d = 1;for (a = 1 ; a <= x ; a ++) {b = a;c = 1;while (b > 0) {c &= b % 2;b /= 2;}d += c;}System.out.println (d);} (a) What output will be printed for input value x = 8 ?(b) How many dierent input values x cause the function to print theresult 8 ?(c) Write a function with the same behavior but only one loop (of anytype) and no library call except for the print statement.Implement a version of the following C function using only the allowed Operators (No loops, other functions, etc) int twosAddOk(int x, int y); determines if two int's can be added without an overflow using only the following operators < <= >= && + ! It isn't supposed to be complicated, but a brief explanation would be nice Full explain this question very fast solution sent me step by step Don't ignore any part all part work u Not:- text typing work do u work12. 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)?
- solve the problem in java:Consider the are n=2 subjects and needed =[4,5]answered questions, to pass.The student has answered =[2,4] questions in the two subjects so far, and can answer another q=1 questions across all subjects combined. The best outcome is to answer an additional question in the second subject on order to pass it, as 2 more answers required to pass the first subject. the max number of subject s that can be passed is 1. the function must return an integer that can represent the max number of subjects that can be passed. public static int maxNumsub(List <Integer> answered, List<Integer> needed, int q){//write code here}This is for Java Write a recursive function that takes as a parameter a nonnegative integerand generates the following pattern of stars. If the nonnegative integer is 4,then the pattern generated is:**********Also, write a program that prompts the user to enter the number of lines inthe pattern and uses the recursive function to generate the pattern. Forexample, specifying 4 as the number of lines generates the above pattern. Java pleaseWrite a C++ program that play the Card Guesssing Game. Your program must give the user the following choices:1. Guess only the face value of the card.2. Gues only the suit of the card.3. Guess both the face value and the suit of the card. Before the start of the game, create a deck of cards. Before each guess, use the function random_shuffle to randomly shuffle the deck.