Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

can anyone do it asap Note : You may use cout and cin CSCE 1040 Lab 10 Assignmen

ID: 3704401 • Letter: C

Question

can anyone do it asap

Note : You may use cout and cin

CSCE 1040 Lab 10 Assignment You are to write a recursive program that determines a sequence of numbers called the liar-liar numbers. Use scanf to input data and printf to output the results. you may use C++ style I/o also You are to work individually. Include your names in the code comments. Failure to include your name may lead to a grade of zero Name your file labl0assignment.cpp. Failure to name the file correctly may lead to a grade of zero The input data will be a single integer value. You may create a file and redirect the contents, but it is not necessary in this lab The assignment must be completed by the end of the lab session 1. 2. 3. 4. Liar-Liar numbers are a sequence of negative numbers in which each number is two times the sum of the previous two negative numbers. The exact formulation for the Liar-Liar sequence is if n-1 if n = 2 2* (Liar-Liar (n-1) +Liar-Liar (n-2)) ifn> 2 Liar-Liar (n) -1 = Your program should generate the Liar-Liar sequence shown below for any value of n such that 1

Explanation / Answer

#include<iostream>

//include below header for formatted output ie out the numbers right justified with field width setting using setw

#include<iomanip>

using namespace std;

int Liar(int n);

int main()

{

for (int i = 1; i <= 23; i++)

{

cout << right<<"Liar-Liar(" << right<<setw(2)<<i << ") " << " = " << setw(14)<<Liar(i) << endl;

}

}

int Liar(int n)

{

if (n == 1 || n == 2)

{

//cout << "Liar-Liar(" << n << ") " << " = " << "-1" << endl;

return -1;

}

else

{

return 2 * (Liar(n - 1) + Liar(n - 2));

}

}

------------------------------

//output

Liar-Liar( 1) = -1
Liar-Liar( 2) = -1
Liar-Liar( 3) = -4
Liar-Liar( 4) = -10
Liar-Liar( 5) = -28
Liar-Liar( 6) = -76
Liar-Liar( 7) = -208
Liar-Liar( 8) = -568
Liar-Liar( 9) = -1552
Liar-Liar(10) = -4240
Liar-Liar(11) = -11584
Liar-Liar(12) = -31648
Liar-Liar(13) = -86464
Liar-Liar(14) = -236224
Liar-Liar(15) = -645376
Liar-Liar(16) = -1763200
Liar-Liar(17) = -4817152
Liar-Liar(18) = -13160704
Liar-Liar(19) = -35955712
Liar-Liar(20) = -98232832
Liar-Liar(21) = -268377088
Liar-Liar(22) = -733219840
Liar-Liar(23) = -2003193856

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote