Write a program that converts all lowercase characters in a given string to its
equivalent uppercase character.
Exercise 2: Battery Model
We want to design a program to manage battery models.
(a) Define a type, BatteryModel, that represents a battery model, that is made of the known voltage , the amount of energy
it is capable of storing, and the energy it is currently storing (in joules).
(b) Define a function PowerDevice that takes as arguments: a current of an electrical device (amps), a battery of type
BatteryModel, and the time the device is to be powered by the battery (seconds), and determines whether the battery's energy reserve is adequate to power the device. If so, the function updates its reserve by subtracting the energy consumed and returns the value 1. Otherwise it returns the value 0 and leaves the energy reserve unchanged.
(c) Define a function MaxTime that takes as arguments: a current of an electrical device and a battery of type BatteryModel,
and returns the number of seconds this battery can operate the device before it is fully discharged. This function may not modify the energy reserve.
Exercise 1: Largest contiguous partial sum
(a) Write a function that will find the largest contiguous partial sum, LagestSum, within an array of real numbers. That is,
we want to sum up any number of neighboring elements from the array, starting from anywhere, find the largest possible
sum.
-3 4 2 1 -4 6 -10 0 -4 3
then the function should report return 9, because 4+2+1+(-4)+6= 9 is the largest sum of contiguous elements from that array of numbers. The function must also provide the starting and the ending indices of the summed elements back to its caller(indices 1 and 5 for the example above).
(b) Write a driver program that tests the function LargesttSum written in (a).
write a function that takes an array of integers as input and prints the second maximum difference between any two elements from an array in python
Write a program to arragne the names in assending order using call by value.
In a library management system auditing is a complex task for a librarian. The stock maintenance has manual entries that may have multiple entries of book access number. The library management system should be automated to remove duplicate book access number. Write a program to remove duplicate numbers using call by reference to a funcftion.
Exercise 1: Largest contiguous partial sum
(a) Write a function that will find the largest contiguous partial sum, LagestSum, within an array of real numbers. That is,
we want to sum up any number of neighboring elements from the array, starting from anywhere, find the largest possible
sum.
-3 4 2 1 -4 6 -10 0 -4 3
then the function should report return 9, because 4+2+1+(-4)+6= 9 is the largest sum of contiguous elements from
that array of numbers. The function must also provide the starting and the ending indices of the summed elements back
to its caller(indices 1 and 5 for the example above).
(b) Write a driver program that tests the function LargesttSum written in (a)
Use the following program to find the scope as mentioned below: #include using namespace std; int square( int y ); // function prototype int main() { int x = 0; for ( x = 1; x <= 75; x++ ) // loop yourrollno times cout << square( x ) << endl; // calculate square of x and output results } // end main // definition of function square int square( int y ) { return y * y ; } // end function square For the program, state the scope (either function scope, global namespace scope, block scope or function-prototype scope) of each of the following elements: a) The variable x in main. b) The variable y in square. c) The function square. d) The function main. e) The function prototype for square.
which contains a list of Annual (Gross) income records of employees in a firm, it should simply print the contents of the file in suitable format on the screen. (Fields (columns) to display in output are: lastname initial, FNPF#, age, GrossIncome and Resident) . Program then prints the list in ascending order of Gross Income. (Fields (columns) to display in output are: FNPF# and GrossIncome) [An algorithm to sort an array is given at the end of this project description Then the user is asked to enter the search initial. If there are employees who have that initial, program prints their record, otherwise a if no students have last names matching the search initial a “no matching record found” message is displayed. The program then calculates and prints to a file IncomeTax.txt, the tax corresponding to the provided Gross Income and the Net Income.exit program
1. C language is an example of imperative / procedural language, but since it is old (no OO or functional programming allowed), is no more required to industry.
True or False
2. Considering an ANSI C compiler what can represent a lexical error?
a. a = )a+(b;
b. a = 0.0a;
c. if (a=3) a++;
d. a = α{"version":"1.1","math":"α"}~b;