Q1) (Greatest Common Divisor) The greatest common divisor (GCD) of two integers is the largest integer that evenly divides each of the two numbers. Write function gcd that returns the greatest common divisor of two integers.
Q: State whether the following are true or false. If the answer is false, explain why.b) Pointers of…
A: Given:- Pointers of different types may not be assigned to one another without a cast operation.
Q: State whether the following are true or false. If the answer is false, explain why.a) A pointer…
A: Answer: Explaination: Void pointer can be dereferenced, but only after type casting it, so if we are…
Q: 4. Design a recursive function that accepts an integer argument, n, and prints every second number…
A:
Q: Sum of two squares def sum_of_two_squares(n): Some positive integers can be expressed as a sum of…
A: Given:- Sum of two squaresdef sum_of_two_squares(n):Some positive integers can be expressed as a sum…
Q: st, and pointers shall be used in this program. Kindly use only SELECTION, ITERATION, INPUT, AND…
A: #include<iostream> #include<fstream> #include<windows.h> #include<string>…
Q: 1. Let A and B two matrices, write a Python3 function to calculate the subtraction of these two…
A: Find Your Code Below
Q: How do you define a function? How do you invoke a function?
A: Define a function in C++ Defining a function in C++ is known as a function definition. it contains a…
Q: - Show the printout of the following code:
A: bool b = true;int i = b; cout << b << endl;cout << i << endl;
Q: Sum of two squares def sum_of_two_squares(n): Some positive integers can be expressed as a sum of…
A: Python code: def sum_of_squares(n): sq = int(n ** 0.5) for a in range(sq, 0, -1): temp…
Q: 6.use c code to Develop a code that gets two integers from the user and calculates and prints their…
A: PROGRAM INSTRUCTIONS: Let us consider a C program that gets two integers from the user and…
Q: 60- In the function, we pass the address of the variable as arguments when using * Call by Reference…
A: your question is about in function we pass the address of the variable as argument when using ___ ?…
Q: 57) By using call by reference can get more than one output of the user defined function.
A: As per the question statement, It is asked to state true or false.
Q: 3- Write a group of statements that carry out the same action of upper and lower functions.
A:
Q: Complete the get_sum_of_evens (lower_bound, upper_bound) function that takes two integer parameters,…
A: Here is the python code: See below step for code.
Q: 1- Choose the statement that does not apply to the following declaration: double [,]…
A: The answer to this question is establishes the maximum number of rows as 4
Q: What is the return type of function id ? a. int b. float c. bool d. dict
A: a) Int is the correct answer.
Q: Complete the code as below mentioned. Write all
A: Here, in this question, we are asked to develop a GO code. It is stated that the amount of potatoes…
Q: Question 4: Total Price Implement the function total_price , which takes in a list of prices of…
A: logic:- define function set total=0 iterate the list using for loop. Set tax=0 if i>=20…
Q: 1. Using the steps in analyzing a problem, show how to solve a problem that obtains two integer…
A: We need to write 5 sub-steps to analyze the given problem. The problem is that we need to take two…
Q: multiplication with three overloaded functions
A: #include <iostream>using namespace std;//class Multiplication.class Multiplication{ public:…
Q: use c++ to Write a function gcd that returns the greatest common divisor of two integers.
A: The largest integer which can perfectly divide two integers is known as GCD.The greatest common…
Q: A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to…
A: def is_leap_year(user_year): if user_year % 100 == 0: #First check if its a century or not…
Q: 12. (Greatest Common Divisor) Given two integers x and y, the following recursive definition…
A: Given: we have to write a program of two integers x and y , the following recursive definition…
Q: Program this
A: The Answer is :-
Q: 5: CheckLetter.cpp) Write a program that adds a check letter to an eight-digit number. The check…
A: Program description : The C++ program, CheckLetter.cpp ask user to enter the 8-digit number .Then…
Q: /* function definition to swap the values */ void swap(int x, int y) { int temp; return e;
A: /*Program to swap value of x nd y using swap function*/ #include<stdio.h> //swap function…
Q: 1. Write a Swift function that takes an array as a parameter and returns a boolean value whether the…
A: Write a Swift function that takes an array as a parameter and returns a boolean value whether the…
Q: Swap two numbers using functions.(no return value, with arguments passed)
A: Given: Swap two numbers using functions. (no return value, with arguments passed)
Q: Please fill in the blanks for the following statements: The ________________ statement passes a…
A: Actually, a parameter pass to a function we use return statement...
Q: Sum of two squares def sum_of_two_squares (n): Some positive integers can be expressed as a sum of…
A: Here is the detailed and simplified answer to the above listed problem statement:
Q: C++ Coding Question, Fill the void function *n1, int *n2, int *n3) void passReference(int ( // Write…
A: Coded using C++.
Q: 5- Write a group of statements that carry out the same action of upper and lower functions.
A: Your answer to write group of statement that carry same action of upper and lower function is given…
Q: C++ Coding Question, Fill the void function *n1, int *n2, int *n3) void passReference(int ( // Write…
A: Coded using C++.
Q: Fill in the missing parts of the following code required to change the be
A: Here is the complete code, which is to be filled. <html><head> <script>…
Q: 3. Write a function called e2_age_range that computes how many people fall within a certain age…
A: Input : Vector A, max_age , min_age Output : Elements of vector in between min_age and max_age.
Q: Assume the following declaration and initialization statements: int x, y, z; x = 3; Assume a…
A: rem(x,&y,&z); one value is passing int and the other two have references for two pointer…
Q: Example 7, 8, 9 7. Continue example 5. Write a print function for sEmployee struct that will print…
A: Algorithm: Start Define a structure with id,name,title and salary as its members Inside main…
Q: te function that is given in question. Do correct.
A: I have complete the code below:
Q: 5. What is the result of the following function in C++ ? (assume all #include and the unseen code is…
A: Please find the answer below :
Q: What does the following function do? float hypot(float x, float y) { return sqrt(x*x+y*y); }//end of…
A: Given that: Find the result of the given function: float hypot(float x, float y) { return…
Q: Write a code to overload area() function that can find the area of circle, rectangle , triangle and…
A: Given: Write a code to overload area() function that can find the area of circle, rectangle ,…
Q: “Days Into Year (C++)” By using my code (photo is attached), implement a Days Into Year function.…
A: A date has to be taken from user in the required format. A function that returns how many days we…
Q: 10-define the function aa(int x,int y) int aa(int x,int y) int aa() void (int x,int y)
A: Function syntax is Return_type function_name (parameter)
Q: d) What is the difference between the following 2 types of functions Operate () Operate (int x)
A: Parameterization is the process of taking values or objects defined within a function or a method…
Q: C Programming-Plz fix this code We can return multiple values from functions using pointers. Let's…
A: Required: C Programming-Plz fix this code We can return multiple values from functions using…
Q: Fill-in-the-Blank A(n)_________ eliminates the need to place a function definition before all calls…
A: Given: Fill in blanks
Q: 2. Modular arithmetic Write a function that returns the result of any integer modulo of n (i.e.,…
A: Actually, function is a group of statements. The given information is: /* precondition: n is greater…
Q: C++ function, operator+(const Matrix& b) const, which returns the matrix *this + b
A: C++ programming language is an object-oriented programming language, that's used to develop mobile…
Q: 60- In the function, we pass the address of the variable as arguments when using • Call by Reference…
A: passing the variable address by using call be reference
Step by step
Solved in 3 steps with 2 images
- integer) Write a function that computes the sum of the digits in an integer. Use the following function header:def sumDigits(n):For example, sumDigits(234) returns 9 (Hint: Use the % operator to extract digits, and the // operator to remove the extracted digit. For instance, toextract 4 from 234, use 234 % 10 To remove 4 from 234, use 234 // 10 (=23) Use a loop to repeatedly extract and remove the digits until all the digits are extracted.) Write a test program that prompts the user to enter an integer and displays the sum of all its digits.Q2) (Perfect Numbers) An integer number is said to be a perfect number if its factors, including 1 (but not the number itself), sum to the number. For example, 6 is a perfect number because 6 = 1 + 2 + 3. Write a function perfect that determines if parameter number is a perfect number. Use this function in a program that determines and prints all the perfect numbers between 1 and 1000. Print the factors of each perfect number to confirm that the number is indeed perfect. Challenge the power of your computer by testing numbers much larger than 1000.1 - Nuclear Power Plant (python) The nuclear powerplant at Threeyedfish will automatically run a program to print a warning message when the reactor core becomes unstable. The warning message reads: NUCLEAR CORE UNSTABLE!!! Quarantine is in effect. Surrounding hamlets will be evacuated. Anti-radiationsuits and iodine pills are mandatory. Since the message contains crucial information, it should be printed three times. To do this, write a function that prints this message. This function has to be used three times.
- Assignment Write a program to calculate n! for a given number n and perform the simple calculator operations. The valid operations of the calculator are: + add - sub * mul I div The program must contain a function fact with one input parameter that returns the factorial of a number, a function add that performs the addition of two numbers, a function sub that performs the subtraction of two numbers, a function mul that performs the multiplication of two numbers, a function div that performs the division of two numbers. The program must also check for bad input data. Make sure when you pass parameters you pass the addresses (not the value). • All function return type must be of type void. • Take inputs in main function. • Pass the addresses of the operands and the address of the result to each function. Output must be displayed as follows: 1: Addition 2: Subtraction 3: Multiplication 4: Division 5: Factorial 6: Quit Enter the choice => 1 Enter two numbers => 2, 3 Sum => 5Programming Language : R programming (R Studio) A twin prime is a prime that has a prime gap of two. Sometimes the term twin prime isused for a pair of twin primes. For example, the five twin prime pairs are (3, 5), (5, 7),(11, 13), (17, 19) and (29, 31). Write a function that returns the number of all twin primepairs between 1 and a given number n.3) A function called isMagic is written below, your task is to write two of the helper functions ckRows and ckSDiagonal. ckRows checks the horizontal rows and ckSDiagonal checks the diagonal going from lower left to upper right. Each function returns true when all the individual sums of rows or the diagonal are equal to the magic number and false otherwise. An example magic square is shown, the size may not always be 3. 2 94 // value will be set, but may not be 5 // value will be set, but may not be 5 const int ROWS = 5; const int COLS = 5; bool isMagic(int arr[][COLS], int magic) { return ckRows (arr, magic) && ckcols(arr, magic) &8 | 75 3 ckMDiagonal (arr, magic) && cksDiagonal(arr, magic); 6 1 8 Your solution should be in this box:
- 1. Square Flower You can have the turtle draw an interesting flower like sha pe by drawing n squares. Each n-square flower is drawn after turning the turtle by some number of degrees between each square. (see Figure 1 for an example) (a) Typel: A 5-square red flower. (b) A 15-square blue flower. Figure 1: Two types of n-square flowers Using the following implementation of draw square() function write a function na med draw flower() that takes a turtle, the number n of squares to draw, the side length and a color as parameters and draws an n-square flower by repeating the function draw square() n times. Test your code by drawing a yellow 21-square flower with side length of 200. def drav aqu ar e (aTurtle, sidelength): f or i in range (4) : aTurtle.forvard (side Length) aTurtle. 1eft (90)#5.Incorrect gurantee downvote. Euler's totient function, also known as phi-function ϕ(n),counts the number of integers between 1 and n inclusive,which are coprime to n.(Two numbers are coprime if their greatest common divisor (GCD) equals 1)."""def euler_totient(n): """Euler's totient function or Phi function. Time Complexity: O(sqrt(n)).""" result = n for i in range(2, int(n ** 0.5) + 1): if n % i == 0: while n % i == 0: n //= i.Question 5: (30 marks) In mathematics, a prime number is a natural number greater than 1 that is not a product of two smaller natural numbers, i.e. is it has only two factors 1 and itself. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime because the only ways of writing it as a product, 1 × 5 or 5 × 1, involve 5 itself. Note that the prime number series is: 2, 3, 4, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, … a. Write a Java method named isPrime that takes a natural number as a parameter and returns the if the given number is prime or not using the following header: Public static boolean isPrime(int num) b. Write a Java class called PrimeNumbers that: o Reads from the user a natural value n (should be less than or equal 200). o Prints a list of the prime numbers from 2 to n and their number and values. o The program has to work EXACTLY as given in the following sample run. Hints: • You should create a single dimension…
- 3) A function called isMagic is written below, your task is to write two of the helper functions ckRows and ckSDiagonal. ckRows checks the horizontal rows and ckSDiagonal checks the diagonal going from lower left to upper right. Each function returns true when all the individual sums of rows or the diagonal are equal to the magic number and false otherwise. An example magic square is shown, the size may not always be 3. 2 9 4 // value will be set, but may not be 5 // value will be set, but may not be 5 const int ROWS = 5; const int COLS - 5; bool isMagic(int arr[][COLS], int magic) { return ckRows (arr, magic) && ckCols(arr, magic) && 7 5 3 ckMDiagonal(arr, magic) && ckSDiagonal(arr, magic); 6 8 Your solution should be in this box: 1.//-In python-// def compute_stats():"""Write a function compute_stats, such that given a string of grades as an input parameter,it calls the function get_new_grades (defined in theprevious question) and returns a tuple that containsthe average value of the initial grades andthe average value after running the get_new_grades function.""" pass The code should aslo have if __name__ == "__main__" section.Python Q1) Write a function get_new_grades, such that given a list of grades as an input parameter,returns a new list where the minimum score isreplaced by 50.Do not modify the initial list! Q2) Write a function compute_stats, such that given a list of grades as an input parameter,it calls the function get_new_grades (defined in the previous questions)and returns a list that contains the average value of the initial list andthe average value of the list from the get_new_grades function.