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 python function Write_String(fanme, *list) which take a list containing string elements and write them in a file myfile.txt until the string “finish” (not case sensitive) occur. The function then returns the contents written in file as a string. Before writing list elements in file, you also need to make a separate python function to check whether input list contains "Finish" or not. If not, then it should return error as shown in example.
myfile.txt:
Python
Java
C
C++
Ruby
.Net
Example-1
Example-2
Example-3
Input:
myfile.txt
["Python", "Java", "C", "C++", "Finish"]
Output:
PythonJavaCC++
Input:
myfile.txt
["Python", "Java", "C", "C++", "Finish",".Net", "Rubby"]
Output:
PythonJavaCC++Input:
myfile.txt
["Python", "Java", "C", "C++"]
Output:
Error: List does not contain Finish
Write a python function Read_Prime(fname, list) which takes a list of numbers as an input, use this number to write them in a file "primes.txt" . The function then read the file and return a list containing only prime numbers as shown in the example. Also, write the exception handling code to show the proper message.
Example-1
Example-2
Example-2
Input:
primes.txt
[1,2,3,4,5,6,7]
Output:
[1,2,3,5,7]
Input:
primes.txt
[3,6,5,13,18,21]
Output:
[3,5,13]
Input:
primes.txt
[2,4,6,8,10]
Output:
[2]
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));
}
In mathematics, the notation n! represents the factorial of the nonnegative integer n. The factorial of n is the product of all the nonnegative integers from 1 to n. For example:
7! = 1 x 2 x 3 x 4 x 5 x 6 x 7 = 5,040
Write a program that lets the user enter a nonnegative integer and then uses a loop to calculate the factorial of that number. Print the factorial to standard output.
Sample Run
Enter a nonnegative integer:7↵
5040↵