Given this function below: int tribonacci(int n) { if (n<=3) return 3; else return tribonacci (n-1) + tribonacci(n-2) + tribonacci (n-3); } What is the output of tribonacci(6)? OA. 12 Ов. 15 Oc. 23 OD. 27
Q: 1. What is the output of the following code? (A)for (int i = 1; i < 4; i++)…
A: Since multiple questions have been asked and it is not clear which one question you want to be…
Q: given the declaration int[]n={1,2,3,4,5}; what is the value of n[4]?
A: The array indexing starts from zero. here n[0] = 1, n[1] = 2 n[2] = 3 n[3] = 4 n[4] = 5
Q: what would be the output of the following program int a[10]={0,1,2,3,4,5,6,7,8,9}; int *p; p = a;…
A: #include <stdio.h> int main() { int a[10]={0,1,2,3,4,5,6,7,8,9}; int *p; p=a; for(int…
Q: 100, n+1, 2log(n), n*ln(n), 2n^2, 2^(n+1), (2n)^n, 2n!, 5n^3, n*3^n.
A: 100 n+1 2log(n) n*ln(n) 2n^2
Q: for (int i = 0, i<5, i++) * true O False O O
A: Given: To declare statement true or false.
Q: Outputs of the following: void main () { int M[3]; int "ptr; ptr=M; *ptr=100; ptr++; "ptr=200;…
A: void main(){ int m[3]; //declaring an array int *ptr; //declaring a pointer ptr=m;…
Q: = x+ x2/2+ x3/3+...... x^/n. Using do-while, write a program to compute f(x) for given x and n. The…
A: import java.util.Scanner;import java.lang.Math;public class Q3 {public static void main(String[]…
Q: Outputs of the following: void main () { int M[3]; int *ptr; ptr=M; *ptr=D100; ptr++; *ptr=200;…
A: Objective: According to the given question, the result of the operations that are included in the…
Q: Try this int x = 6; X++; --X; X += 2; cout << x++ << "\t" cout << --X;
A: The given code is below: int x=6; x++; --x; x+=2; cout<<x++<<"\t";…
Q: Write a program to generate a set of random numbers confined between the open period ( _2 ,+2),…
A: You have not specified any programming language in the question. So, I have used python language to…
Q: Program fragment int a[5] = {5, 1, 3, 2, 7}; for (int k= 0; k< 5; k++) a[k] = a[4 - k]; %3D for (int…
A: Program fragment: int a[5] = {7, 2, 3, 1, 5}; for (int k = 0; k < 5; k++) a[k] = a[4 - k]; for…
Q: What is the value of the variable ss after the following code is executed? int x[ 7 ] =…
A: In the given program, an array of size 7 is defined which contains 6 elements. Then, a variable ss…
Q: what is the output of the following code? Static linearqueue q. int a ] = {1, 3, 5, 7,9, 11, 13, 15,…
A: Queue is a data structure which follows the FIFO (first in, first out) principle. Enqueue always…
Q: int RFunc(int a, int b) { if (a <= 0 || b <= 0) { return a+b; } else { return RFunc (a-1, b-1) +…
A: HERE IS STEP BY COMPLETE SOLUTION REGARDING YOUR PROBLEM
Q: Given int a = 1, and double d = 1.0, what is the result of d+= 1.5*3 + (++a)? O A. 7.5 O B. 6.5 O C.…
A: Given int a=1 double d=1.0
Q: a) Consider the following code and write the output of this code? int **p;p = new int* [5];for (int…
A: Objective: We need to specify the output of the first source code. Also, the error should be…
Q: What would be the output of the following program int a[10]=(0,1,2,3,4,5,6,7,8,9}; int *p; for (int…
A: Objective: Given a set of lines of code in c language to predict output
Q: the out put of the following is { int v=0; do cout << ++v ; while ( v< 5 ); } 012345 O 12345 01234 O…
A: Here, we are going to trace this code and try to find out the output.
Q: Consider the code char x = 'A'; void test(int n) printf("%d ", n); if(n > 0) Missing 1 if(n == 0)…
A: Given: Executing Code.
Q: int X[10]={2,0,6,11,4,5,9,11,-2,-1); %3D From the code above, what is the value of X[8] ?
A: Code: #include <iostream>using namespace std; int main(){ //as index value starts from 0…
Q: write a program that asks the user to type an integer N and compute u(N) defined with: u(0)=3 u(1)=2…
A: ## As no programming language mentioned, the code is written in Python. def u(n):…
Q: void foo(int n) { } int i; for (i = 0; i 0) i = 1 / 2;
A:
Q: Given the following piece of code : int i, sSum = 0; for(i=1;i<7;i++) sum+=2; What is the value of…
A: Code: #include <iostream>using namespace std;int main(){int i,sum=0;//declaring the variables…
Q: What is the output of the following code segment? int random[3] [4] = {{6,7,3,1),{4,8,2},{5,9}}; int…
A: The outer for loop executes from i=0 to i=2 The inner for loop executes from j=2 to j=i
Q: Investigate the output 12 16 20 24 15 20 25 30 18 24 30 36 And find the values for variables start,…
A: start=4 end=6 first=3 last=7
Q: Suppose that x and y are of type int, z is of type double, and ch is of type char. cin >>x >» y If…
A: The given small code belongs to C++. Correct answer is provided below with an explanation why it is…
Q: Given the following function: int Rec(int n) { } if (n == 0) else return 0; return Rec(n-1) +…
A: we have: int Rec(int n) { if(n==0) return 0; else return Rec(n-1) + (3*n-2);…
Q: Write a Javascript function that will ask the user to input a list of numbers. The numbers will be…
A: JavaScript function used: prompt() -> use to take user inputted numbers from the browser alert()…
Q: Write a program which ends when a user types a user- defined letter. 1. Get an english letter as a…
A: Algorithm: do{ // loop body }while(condition);
Q: char letters[26]; for(int i = 0; i < 26; i++) { letters[i] = 'A' + i; } printf("%c",…
A: The above code does not include the main function. It gives error in compilation. The correct code…
Q: What is the output of the following code: int multiply(int &a, int &b); int d=3 main () {int…
A: Output is 2 3 6 8 4 Option b.2 3 6 8 4 is the answer
Q: Q2) Write and test the following power() function that returns x raised to the power n, where n can…
A: C++ Code for Above : #include <bits/stdc++.h> using namespace std; //power function double…
Q: Consider the following code and write the output of this code?
A: 2 3 4 4 5 6 6 7 8 8 9 10
Q: || What is the coutput of the following statement: int x, y, Z; double w, t; X= 9; y = 21; x = x + y…
A: The code is made on Dev C++ and the output is taken out by performing the calculations.
Q: Consider the following code snippet : for ( int i = 4; i > 0 ; i --2) { %3! for ( int j = 2; j >=0;…
A:
Q: Improve the given code below, make sure that the code will require input from the user. Problem:…
A: Please find the answer below :
Q: Find output of below program int main() { int c1,c2; int a = -8; int b = 3; c1 = --a + b; c2 = a--…
A: Given: Find output of below program int main(){int c1,c2;int a = -8;int b = 3;c1 = --a + b;c2 = a--…
Q: Write a program that reads a list of integers, and outputs whether the list contains all even…
A: PROGRAM: #Function definition def is_list_even(my_list): #Iterating list elements for x in…
Q: Consider the following code fragment: int reps = 10; int x = 0; int y, z; y = (3 + 10) / 5; z = 3 +…
A: Consider the following code fragment int reps = 10; int x= 0; int y ,z; y=(3+10)/5;…
Q: : What is the output : ;int i = 1, n = 2 } while (i < 3) ;n = n+ i ;++ i ;++n
A: Here, Code is given.
Q: What is the value of the variable ss after the following code is executed? int x[ 7 ] =…
A: The answer of the question is given below
Q: Given: int d=2, e=4; bool f = 0; %3D f = (e%d==0); What is the final value of f?
A: #include <iostream> using namespace std; int main() { int d=2; int e=4; bool f =0;…
Q: int = (0,0,1); for (int i=0;i0) D[i][j] = i*j; else D[i][j] = i + j; c[i]+= D[i][j]; }
A: Please check the image below for the execution of the given program or code. This java program will…
Q: int a[ ] = {1, 1, 2, 3, 5, 8, 13, 21}; for (int n = 0; n < 5; n++) { = a[n+1]; a[n] a[n+1] = a[n+2];…
A: import java.util.*;public class Main{ public static void main(String []args) {…
Q: Q3 What is printed by the following code fragment? Int x₁=2, y₁.x₂= 5.Y2; y₁=++X₁; Y2=(x2)++;…
A: initially, x1 = 2, x2 = 5. after , y1 = ++x1 // y1 = 3, x1 = 3, x2 = 5. after, y2 =…
Q: What is the value of the variable ss after the following code is executed? int x[ 7 ] =…
A: The C++ for loop is used to iterate a part of the program several times
Q: Consider the following code fragment. What is the output for each of the following input values…
A: Here the nested if-else statement is used. In a nested if-else statement, the first if condition is…
help me with c
Step by step
Solved in 3 steps
- 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…Create the generated machine code from snippet code as follow: int i=10, j, x;for (a=10; a>0; a--) {if (a % 2 == 1) i += a;else i /= 2;j = i*2;}x = i+j; please solve max in 30 minutes thank uWrite a recursive function int fib (int n) to compute the Fibonacci numbers where n is a positive integer.Write an application (main() function) using command line parameters that calls fib(n) and outputs n,fin(n), fib(n)*1.0/fib(n-1) for n = 3,4,5,6,7,8,9,10,11,12,13,14,15In a format fprintf (stdout,“n = %d\tfib(n) = %d\tfib(n)/fib(n-1) = %.4f\n”, n, fib(n), fib(n)*1.0/fib(n-1))The ratio of fib(n) to fib(n-1) for large values of n (larger than say 10) is called the golden ratio.Plot a curve between n and golden ratio.Submit the assignment by dropping the MS word file containing the program code, results (take a screenshot of the Cygwin/ubantu) and paste to the word file in C
- Write a function that prints a diagonal line using asterisk characters. Your function should accept one parameter that determines the number of rows defining the length of the diagonal line. This value will always be a positive integer greater than or equal to 1 (e.g. 1, 2, 3, …). use this Java: public static void printPattern( int num );1 int[] a = new int[n]; 2 a[0] = 0; a[1] = 1; 3 int x = 0; 4 for (int i = 2; i < n; i++) { 5 x = 3 * (i-1) * (i-1); 6 x += 3 * i - 2; 7 a[i] = a[i-1] + x; 8 } The code can be simplified by replacing lines 5, 6, 7 with a single line of code. Write the single line of code below: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 ra
- 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?Does this function work? For example: $16.65 has 66 quarters, 1 dime, 1 nickel, and 0 pennies. If it doesn't work can you explain what the problem is. def coins(total, denomination): num = int(total / denomination) print(num, " ", end="") if denomination == 0.25: print("quarters") elif denomination == 0.10: print("dimes") elif denomination == 0.05: print("nickels") else: print("pennies") return total - (num * denomination)#----main----money = float(input("How much money do you have? > "))print()print("Your money in coins would be:")money = coins(money, 0.25)money = coins(money, 0.10)money = coins(money, 0.05)money = coins(money, 0.01)Consider the following recursive function:void recEx11(int x){if (x > 0)if (x % 2 == 0){recEx11((x - 3) / 2);cout << x << " ";}else{recEx11((x - 4) / 2);cout << x << " ";}}What is the output of the following statements? a. recEx11(28); b. recEx11(148); c. recEx11(98); d. recEx11(-30)
- 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 please1. What is the output of the following code? (A)for (int i = 1; i < 4; i++) {System.out.println("Count is: " + i);}(B)for (int i = 1; i <= 3; i++) {for (int j = 1; j <= 3; j++) {System.out.print((i * j) + " ");}System.out.println(); // to go to next line} 2. Write a program called ListOddNumbers that prints the below (there is a single spacebetween each number). Printing odd numbers between 1 and 501 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 3. Write a program called NestedLoop that prints the below. Use a for nested loop. You need to use if nested loop. 122333444455555int a[10] = {0,1,2,3,4,5,6,7,8,9};int *m = &a[0];int *p = &a[5];int *q = &a[1]; p = (int) m + (int) p - (int) q; what is the value of of *p