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.
Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in the string. The output should include the input character and use the plural form, n's, if the number of times the characters appears is not exactly 1.
Write a c++ program that takes your name from keyboard and display the following if your name has 10 character your name is too long if it comprise between 5 and 9 character your name is medium if it comprise less than 5 character your name is too Short
Write a C++ program that reads 10 integer numbers and stores them in an array Numbers, sorts the numbers using the bubble sort algorithm, and displays the array elements whenever there is an element swap. This C++ program must have three functions: 1. reading the array's ten elements, 2. displaying the array's elements, 3. The array elements are being sorted.