Write a function GCD( int A, int B ), when called from main function, returns the GCD (Greatest Common Divisor) of two numbers. Also get two numbers, X and Y from user and call this function to calculate GCD and show the result on Monitor. X and Y must be your reg# and 786, respectively. Note: GCD, Greatest Common Divisor: GCD of two numbers is the greatest number which can divide both the numbers. If the smaller of the two numbers can divide the larger number then the GCD is the smaller number. Else starting from 1 to (smaller / 2), check whether the current element divides both the numbers . If yes, then the highest of these devisors is the required GCD.
Q: Question 2: Write a program that defines a function, RoundToThousands(number), to round a number x…
A: Step 1:- Program Approach:- 1.Declare the user-defined function that function takes one parameter.…
Q: 2. The function function1 is defined as following def function1(aNumber): for n in range (2,…
A: a. Objective of the function: The given function “function1” is used to check a range of numbers…
Q: Write a function max_magnitude() with two integer input parameters that returns the largest…
A: Python function for above : # required function def max_magnitude(user_val1, user_val2): if…
Q: The function doit(a,b,c,d) is a function that multiplies the smallest of its integers arguments by…
A: C Program: #include <stdio.h> //function prototypevoid doit(int,int,int,int); int main() {…
Q: Write a function that makes the first number as large as possible by swapping out its digits for…
A: function maxPossible(n1, n2) { arr1 = n1.toString().split('') arr2 =…
Q: Write a function that receives 3 assignment grades, a1, a2, a3, and a final grade, f, for a student…
A: #include <iostream> #include<cmath> using namespace std; double gradeCalc(int a1, int…
Q: Given the following function: def nPrint (message, n): while n > 0: print (message, end='') n -= 1…
A: Here in this question nprint (a, 4 ) is called..so until while condition is true..it will go inside…
Q: Write a function that asks the user how many Fibonacci num- bers to generate and then generates…
A: In the below step you can find the complete code.
Q: Write, test, and execute a function that accepts the values of a, b, and c as parameters from a…
A: Introduction of Program: This C++ Program takes the value of a,b, and c from the user and then the…
Q: .Write a function absolute(x) that prints the absolute value of x
A: abs(x)- This method returns absolute value of x - the (positive) distance between x and zero.
Q: 2. There is a defined function called multiplierSum(n) which returns the sum of all multipliers of a…
A: Program plan: Define function multiplierSum(n) which prints the sum of all multipliers of a…
Q: Create a function that determines whether the number is Oddish or Night. The number is Oddish if the…
A: Algorithm - declare a variable sum = 0 Now add while loop on num use the below logic sum +=…
Q: Given two overloaded functions below. int f(int &a, int b) { int c = a + b; a = a+1; b = b+1; return…
A: Consider the first function: int f(int &a,int b) { int c=a+b; a=a+1; b=b+1; return c; }
Q: Write a function with name 'sum' to find the result of mathematical function given below. Your…
A: int sum(int n,int m,int k){ int temp=0; if(m<n){ //swapping m and n if m<n…
Q: 2. Given the following function A(a, b), what does A(8, 3) return? 1 function A(a, b) 2 if b = 0 3…
A: code:
Q: Write a function highLow that takes an integer as an argument and returns whether or not the number…
A: Since the language is not specified, the below code is in python. The algorithm for the program:-…
Q: The least common multiple (lcm) of two positive integers u and v is the smallest positive integer…
A: Code: #include <stdio.h>//function returns the GCDint gcd (int u, int v){ int x; while ( v…
Q: Given a function below: int func (int num1, int num2=0, int num3=0) {return num1+num2+num3;} If we…
A: auto new_value=func(1,,2); in the above function call you must pass a value because the syntax…
Q: To convert between Celsius and Fahrenheit, the following formula is used, where C = Celsius…
A: In this program, you need to write function called toCelsius() which will convert Fahrenheit…
Q: Defining a binary number as Program 1, write the function int binToDec(const int bin[]) to convert…
A: Actually, program is a executable software that runs on a computer.
Q: Suppose you have written the following function. function salesTax(price, rate) { let tax =…
A: Ans: Suppose you have written the following function. function salesTax(price, rate) { let tax =…
Q: Write a function max_magnitude() with two integer input parameters that returns the largest…
A: Step 1 The code is given in the below step
Q: Help.
A: The given program is defining the function swapints with two integer values. The swapints function…
Q: Write a program which will take marks of three quizzes as input, then call a function void…
A: Program Plan:- Initialize the header files. Take the marks of the quizzes from the user. pass them…
Q: Remember that an integer n is prime if (i) n > 2 and (ii) it is only divisible by 1 and n itself.…
A: To check whether a number n is prime or not, divide the it with all number from 2 to n/2. If the…
Q: Define a function print_feet_inch_short(), with parameters num_feet and num_inches, that prints…
A: PROGRAM CODE: # start the definition of the function to print feet and inchesdef…
Q: Write a function "DivRemain" that will return both the dividend and the remainder from dividing two…
A: #include <iostream>using namespace std; int* DivRemain(int n1, int n2){ int* arr = new…
Q: Write two functions that implement the following conversions: a. Function celsius receives a…
A: Program: #include<bits/stdc++.h> #include <iostream> using namespace std; float…
Q: float theRealQuestion (int x, float y) { int z; if (x > 15) z = x; else z = y; return…
A: In this question, function is given and we have to code the function prototype. As the language is…
Q: Write a function that raises an integer to a positive integer power. Call the function x_to_the_n()…
A: //here i am writing my c code #include<stdio.h>//header file#include<math.h>//header…
Q: Write a program which consists of a user defined function: compute (), it should take one integer…
A: Programming Language used: C language C Code for the given scenario, is as follows: #include…
Q: Write the definition of a function absoluteValue that receives a parameter containing an ue and…
A: Lets see the solution.
Q: Write a function ones_and_tens_digit_histogram(numbers) that takes as input a list of numbers and…
A: #required functiondef ones_and_tens_histogram(_list): #via list comprehension _list =…
Q: Remember that an integer n is prime if (i) n > 2 and (ii) it is only divisible by 1 and n itself.…
A: To check if a number is prime or not, divide the number n by every number from 2 to n/2. If it is…
Q: Write a function that takes two integers and returns True if the integers have a common divisor that…
A: Required: Write a function that takes two integers and returns True if the integers havea common…
Q: Write a function named sumDigits which takes three parameters: f, t and x. sumDigits, then, finds…
A: function sumDigits(f,t,x): Start for i in f to t follow steps 3 to 10 Number = i initialize Sum = 0…
Q: Create a function that determines whether a number is Oddish or Evenish. A number is Oddish if the…
A: function oddishOrEvenish(num) { let arr = num.toString().split(''); let sum =0; for (let i of arr){…
Q: Write a function that takes an integer input and check whether it can be expressed as the sum of two…
A: C++ Code for above : #include <bits/stdc++.h> using namespace std; //function to check if…
Q: The least common multiple (lcm) of two positive integers u and v is the smallest positive integer…
A: Program: #include <stdio.h> int gcd (int u, int v){int temp;while (v != 0){temp = u % v;u =…
Q: Write a function for the Superman ride at Six Flags that determines whether the user is taller than…
A: Program code to write a function for the Superman ride to determines whether the user is taller…
Q: Define a function print_feet_inch_short(), with parameters num_feet and num_inches, that prints…
A: According to the information given:- create a function:- print_feet_inch-short() parameters…
Q: Write a function that receives the left, bottom, right and top coordinates of two rectangles, and…
A: Program for given condition :- def intersection(l1, b1, r1, t1, l2, b2, r2, t2): """ Function…
Q: Write a function that takes the current date and corrects the number of days, if it's wrong. The…
A: Actually, function is a group of statements.
Q: Write a function sumOddInts(). sumOddInts should return the sum of all odd integers between the…
A: Note: Programming language: Python def sumOddInts(a,b): s=0 #store the sum of odd between a and…
Q: Write a function GCD( int A, int B ), when called from main function, returns the GCD (Greatest…
A: Dear Student, As no programming language is mentioned I am programming it in C++.
Q: Write a function that takes one argument, an integer, and returns the value of the following 1117…
A: Below I have provided a python program for the given question. Also, I have attached a screenshot of…
Q: In this excersie the main function calls Series1 and/or Series2 functions and you are required to…
A: Code is given below #include <iostream> using namespace std; int fact(int n)…
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 that accepts an integer as it's only argument. The function calculates and returns…
A: The required function in python is : def Func1(t): s=0…
Q: Write a function named secondLargest() to keep asking the user to enter a series of numbers that…
A: def secondLargest(numbers): lst = numbers.split(" ") lst.sort(reverse=True) #Sort list in…
Step by step
Solved in 3 steps with 1 images
- Because of the outbreak of the Coronavirus (COVID-19), visitors from infested countries and regions have to be quarantined for 14 days which is 14 X 24 X 60 = 20160 minutes! Write a function Min2DHM(minutes) that takes the number of minutes as a parameter and converts that number of minutes into a specific format below: Day(s): Hour(s): Minutes(s) Note: You can assume the number of minutes is between 0 and 20160 and here is the expected output of your function.1. Fibonacci series can be created starting from 0 to the desired number. A function can be written for this operation and it can take two parameters: start and end. The default fırst parameter 0 is acceptable. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765..The least common multiple (lcm) of two positive integers u and v is the smallest positive integer that is evenly divisible by both u and v. Thus, the lcm of 15 and 10, written lcm(15, 10), is 30 because 30 is the smallest integer divisible by both 15 and 10. Write a function lcm() that takes two integer arguments and returns their lcm . The lcm() function should calculate the least common multiple by calling the gcd() function from program 7.6 in accordance with the following identity
- The least common multiple (lcm) of two positive integers u and v is the smallest positive integer that is evenly divisible by both u and v. Thus, the lcm of 15 and 10, written lcm(15, 10), is 30 because 30 is the smallest integer divisible by both 15 and 10. Write a function lcm() that takes two integer arguments and returns their lcm . The lcm() function should calculate the least common multiple by calling the gcd() function from program 7.6 in accordance with the following identity: lcm(u, v) = uv / gcd(u, v) u, v >= 0Define stubs for the functions get_user_num() and compute_avg(). Each stub should print "FIXME: Finish function_name)" followed by a newline, and should return -1. Each stub must also contain the function's parameters. Sample output with two calls to get_user_num() and one call to compute_avg(): FIXME: Finish get_user_num() | FIXME: Finish get_user_num() FIXME: Finish compute_avg() Avg: -1 354684.2266598.qx3zgy7 2 Your solution goes here ''' 4 user_num1 5 user_num2 6 avg_result get_user_num() get_user_num) compute_avg(user_num1, user_num2) 8 user_num1 9 user_num2 10 avg_result %3D 11 12 print('Avg:', avg_result)Write a function that takes 4 Inter gets (num1, den1,num2,den2) as parameters which represent the rational numbers num1/den1, num2/den2 and returns the division of these two fractions. A/B ÷ C/D = A/B × D/C = AD/BC • den 1, den2, and num2 can not be zero. • use multiplication_rat function.
- Write a function called subsequence() that finds the longest common subsequence of two DNA strands. The function should take two DNA strands (strings) as input and should return the longest common subsequence. Example:subsequence(“AATTCAT”, “CAT”) returns “CAT”subsequence(“CAAAT”, “CAT”) returns “CA”subsequence(“CCG”, “TTA”) returns “”subsequence(“AATGTTACCC”, “AATCTTACCT”) returns “TTACC”subsequence(“AATCTTAGCC”, “AATCAAAGCC”) returns “AATC”If there are multiple subsequences of the same length, then return the firstDefine stubs for the functions get_user_num() and compute_avg(). Each stub should print "FIXME: Finish function_name()" followed by a newline, and should return -1. Each stub must also contain the function's parameters.Sample output with two calls to get_user_num() and one call to compute_avg(): FIXME: Finish get_user_num() FIXME: Finish get_user_num() FIXME: Finish compute_avg() Avg: -1 ''' Your solution goes here ''' user_num1 = 0user_num2 = 0avg_result = 0 user_num1 = get_user_num()user_num2 = get_user_num()avg_result = compute_avg(user_num1, user_num2) print('Avg:', avg_result)Define stubs for the functions get_user_num() and compute_avg(). Each stub should print "FIXME: Finish function_name()" followed by a newline, and should return -1. Each stub must also contain the function's parameters. Sample output with two calls to get_user_num() and one call to compute_avg(): FIXME: Finish get_user_num( ) FIXME: Finish get_user_num() FIXME: Finish compute_avg() Avg: -1 Learn how our autograder works 461710.3116374.qx3zqy7 1234 3 111 Your solution goes here ** 4 user_num1 = 0 5 user_num2 = 0 6 avg_result = 0 7 8 user_num1 = get_user_num() 9 user_num2 = get_user_num() 10 avg_result = compute_avg(user_num1, user_num2) 11 12 print (f'Avg: {avg_result}')
- Please code in python Using the function from the previous problem, write a function durdle_game(target) which takes in as an argument a single string that will be the target to guess, and lets the user attempt to guess the target word. Each time the user makes a guess, the function will print out the result of the previous function to tell the user how close they are. If the user guesses correctly, then the game is over. Have the function return the number of guesses that it took the user to get the correct answer Hints: You may assume that the target and all of the input strings are 5 letters and all lowercase.The function doit(a,b,c,d) is a function that multiplies the smallest of its integers arguments by 2. If more than one arguments are equal and are the smallest, they are multiplied by 2. For example given a=5,b=3,c=7,d=9, doit (a,b,c,d) changes b to 6. Write the code of the function doit and test it.Create a function that returns true if there's at least one prime number in the given range (n1 to n2 (inclusive)), false otherwise. Examples primeInRange (10, 15) true // Prime numbers in range: 11, 13 primeInRange (62, 66) false // No prime numbers in range. primeInRange (3, 5) → true // Prime numbers in range: 3, 5 Notes n2 is always greater than n1. n1 and n2 are always positive. • 0 and 1 aren't prime numbers.