STRING REVERSE PROGRAM
Create a program that will apply recursive functions.
The program should accept a string say SUBJECT.
The output of the program should be TCEJBUS .
Screen/Layout
Input a string: SUBJECT
After a reverse: TCEJBUS
Try Another[Y/N]: Y
Input a string: face
After reverse: ecaf
Try Another[Y/N]:N
Instructions:
1. In the code editor, you are provided with a main() function that asks the user for 4 integer inputs and passes these to the getBest() function call.
2. Your task is to declare and define this getBest() function which has the following details:
Return type - int
Name - getBest
Parameters - 4 integers
Description - returns the highest integer passed
DO NOT EDIT ANYTHING IN THE MAIN
Input
1. First integer
2. Second integer
3. Third integer
4. Fourth integer
This is the given code:
#include <iostream>
using namespace std;
int main(void) {
int a, b, c, d;
cout << "Enter a: ";
cin >> a;
cout << "Enter b: ";
cin >> b;
cout << "Enter c: ";
cin >> c;
cout << "Enter d: ";
cin >> d;
cout << "Highest integer = " << highest;
return 0;
}
Instructions:
1. Your task is to ask the user for a character input.
2. Then, include the cctype built-in library and call the toupper() function. In case you do not know what this function is, this function has the following definition:
Return type - int
Name - toupper
Parameter - one integer which represents the ASCII of a character
Description - returns the ASCII of the uppercase equivalent of the character passed
Extra note - even though it's function definition in the C++ Programming Language Documentation is int toupper(int ch), you can just pass a normal char variable instead and this will just be automatically typecasted/converted to its integer equivalent.
3.Once you get the uppercase equivalent, print this out.
Input
1. Letter to be updated
Instructions:
1. You are provided with the isLeapYear() function which is already declared and defined for you.
2. Your task is to ask the user for a year and then call the isLeapYear function to check whether the year is a leap year or not.
Input
1. Year to be checked
Output
If a certain year is a leap year, print "<INSERT_YEAR_HERE> is a leap year"
Otherwise, print "<INSERT_YEAR_HERE> is not a leap year"
Sample Output:
Enter·year:·2020
2020·is·a·leap·year
This is the given code:
#include <iostream>
using namespace std;
int isLeapYear(int);
int main(void) {
// TODO: Write your code here
return 0;
}
int isLeapYear(int n) {
if(
(n % 4 == 0 && n % 100 != 0) ||
(n % 100 == 0 && n % 400 == 0)
) {
return 1;
}
return 0;
}
Instructions:
1. In the code editor, you are provided with a main() function that asks the user for an integer input n, and passes this value to the function call of the generatePattern() function.
2. Your task is to implement this generatePattern() function which has the following description:
Return type - void
Function name - generatePattern
Parameters - 1 integer n
Description - this function prints a triangular pattern of letter T's based on the value of n. For more information, refer to the output in the test cases
3.DO NOT EDIT ANYTHING IN THE MAIN
Input
1. Integer n
This is the given code:
#include <iostream>
using namespace std;
int main(void) {
int n;
cout << "Enter n: ";
cin >> n;
generatePattern(n);
return 0;
}
1. In the code editor, you are provided with a main() function that asks the user for 2 characters, passes these characters to a function call of the getHigherValue() function, and then prints out the ASCII value of the higher character.
2. Your task is to implement the getHigherValue function which has the following details:
Return type - int
Name - getHigherValue
Parameters - 2 characters to be compared
Description - the ASCII value of the higher character.
3. Hint: Comparing characters in C++ is just like comparing integers.
4. DO NOT EDIT ANYTHING IN THE MAIN
Input
1. First character
2. Second character
This is the given code:
#include <iostream>
using namespace std;
int main() {
char a, b;
cout << "Enter first character: ";
cin >> a;
cout << "Enter second character: ";
cin >> b;
cout << "Result value = " << getHigherValue(a, b);
return 0;
}
write a program that compiles and executes but computes wrong because of a comment that was not close
Draw the stack diagram for the following code if 7 is entered
Code:
int FibonacciSeries(int n)
{
if((n==1)||(n==0)) return(n);
else return(FibonacciSeries(n-1)+FibonacciSeries(n-2));
}
Task:(only diagrams are needed no code)
Draw stack frame diagrams of the following recursive function if 200 is entered by the user :
Code:
int FibonacciSeries(int n)
{
if((n==1)||(n==0)) return(n);
else return(FibonacciSeries(n-1)+FibonacciSeries(n-2));
}
Write a Program: Print a table of stars and zeroes. Your goal is to print a square table of alternating stars and zeroes. Ask the user to enter a size of the table. This number should be odd. Since the table is square the number of rows and columns will be the same and should be equal to the entered size. The valid range for the size is from 3 to 15, inclusive. Use a loop to make sure the entered size is odd and within the range. Output a descriptive error message if an invalid size is entered. The error message should indicate if the size is even, or less than the minimum, or larger than the maximum. Do not create separate output strings for all combinations of error conditions – your program should build the output.
Once a valid size is entered print the table to the console. Each row of the table should have alternating ‘*’ and ‘0’ symbols separated by a space. Each column of the table should also have alternating ‘*’ and ‘0’ symbols. All corners should have the ‘*’ symbol.