Exercise 2: RISC-V functions 1. Write a function penta in RISC-V that, when given an integer , re...
Problem 2 (USE C++) Assume you are given two functions: a function that returns –in a variable passed by reference- the GCD of all integer numbers in an array void GCD(int A[], int size, int &g) and another function that allows you to divide all numbers of an array by a given integer void Div(int A[], int size, int gcd) (assume the functions are in a library, therefore you don’t need to implement them, but just use them). 1. Write...
(Palindrome integer) Write the functions with the following headers: # Return the reversal of an integer, e.g. reverse(456) returns # 654 def reverse(number): # Return true if number is a palindrome def isPalindrome(number): Use the reverse function to implement isPalindrome. A number is a palindrome if its reversal is the same as itself. Write a test program that prompts the user to enter an integer and reports whether the integer is a palindrome.
use coral language please
question 1
Function ConvertFeetToInches(integer feetToConvert) returns
integer resultInches
resultInches = feetToConvert * 12
Function Main() returns nothing
integer resultInches
integer feetToConvert
feetToConvert = Get next input
// Your solution goes here
Put feetToConvert to output
Put " feet are " to output
Put resultInches to output
Put " inches." to output
question 2
Function GetRecArea(float recHeight, float recWidth) returns
float recArea
// Calculate recArea:
recArea = 0
Function Main() returns nothing
float userHeight
float userWidth
userHeight...
Please help with this SML problem.
4. Write recursive functions for the following: (a) Given an integer i and a list L, cycle L i times. That is, if, L = [a1, A2, ... , an], then the desired result is [di+1, Q i+2, ... , An, Q1, Q2, ... , ai] (b) Compute x', where x is a real and i is a nonnegative integer. This function takes two parameters, x and i.
Python Please Write a recursive function rPatt that, when given a power of 2 as an argument, returns the patterns indicated in the examples. OutPut: >>> rPatt(1) '|' >>> rPatt(2) '|--|' >>> rPatt(4) '|--|----|--|' >>> rPatt(8) '|--|----|--|--------|--|----|--|' >>> rPatt(16) '|--|----|--|--------|--|----|--|----------------|--|----|--|--------|--|----|--|' >>> rPatt(32) '|--|----|--|--------|--|----|--|----------------|--|----|--|--------|--|----|--|--------------------------------|--|----|--|--------|--|----|--|----------------|--|----|--|--------|--|----|--|' >>>
1)
a) Write MATLAB function that accepts a positive integer
parameter n and returns a vector containing the values of the
integral (A) for n= 1,2,3,..., n. The function must use the
relation (B) and the value of y(1). Your function must preallocate
the array that it returns. Use for loop when writing your code.
b) Write MATLAB script that uses your function to calculate the
values of the integral (A) using the recurrence relation (B), y(n)
for n=1,2,... 19...
1. Write an iterative C++ function that inputs a nonnegative integer n and returns the nth Fibonacci number. 2. Write a recursive C++ function that inputs a nonnegative integer n and returns the nth Fibonacci number.
Please do the following problems 1. translate into RISC-V Assembly variable rpt in x19 register. if(rpt>0){ rpt=rpt-1; goto loop } 2. Translate the following Risc-V code into C. variable 'i' in register x5, variable 'result' in x6 ,base address of integer 'memarray' in x10 addi x6,x0,0 addi x29,x0,100 LOOP: ld x7,0(x10) add x5,x5,x7 addi x10,x10,8 addi x6,x6,1 blt x6,x29, LOOP
Write program in C++: Function name: Average1D: The Function takes an integer array of 1 Dimension of any size that is given from the main program. The function returns the average of the numbers that less than or equal to 50.